Created
July 5, 2013 11:40
-
-
Save zmalltalker/5933987 to your computer and use it in GitHub Desktop.
HTTP 100 continue with wget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "socket" | |
server = TCPServer.new("0.0.0.0", 9999) | |
count = 0 | |
loop do | |
count = count + 1 | |
client = server.accept | |
req = client.readline | |
client.readline | |
if count > 3 | |
client.puts "HTTP/1.1 200 OK" | |
client.puts "Content-Type: text/plain" | |
client.puts "Content-Length: 10" | |
client.puts "Connection: close" | |
client.puts | |
client.puts "1234567890" | |
count = 0 | |
else | |
client.puts "HTTP/1.1 100 CONTINUE" | |
client.puts "Content-Type: text/plain" | |
client.puts "Content-Length: 0" | |
client.puts "Connection: close" | |
client.puts | |
end | |
client.close_write | |
end |
The use case was that an app responded to an expensive request (generate a git tarball} by putting a message on a queue and returning an empty 202 response. Wget would consider this empty response a success. Http 100 would make it retry.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool. What's the use-case here? Why can't you just hold onto the connection?
BTW:
100 Continue
will never have a body, so it should work withoutContent-Length
.