Created
October 25, 2013 22:50
-
-
Save thinkerbot/7163006 to your computer and use it in GitHub Desktop.
Rack streaming via puma.
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
# puma | |
# curl http://localhost:9292/ | |
# | |
# Note chrome buffers like 1024 or so... meaning the first lots will look missing. | |
run lambda { |env| | |
body = lambda { |io| | |
io.sync = true | |
10.times do |i| | |
n = 2 | |
str = (i.to_s * (n - 1)) + "\n" | |
io.write "#{str.length.to_s 16}\r\n" | |
io.write "#{str}\r\n" | |
sleep 1 | |
end | |
io.write "0\r\n" | |
io.write "\r\n" | |
io.close | |
} | |
headers = { | |
"Content-Type" => "text/plain", | |
"Cache-Control" => "no-cache", | |
"Transfer-Encoding" => "chunked", | |
'rack.hijack' => body | |
} | |
[200, headers, nil] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment