diff options
author | Eric Wong <e@80x24.org> | 2013-10-30 01:50:10 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-10-30 07:00:53 +0000 |
commit | e07ce2ae90195a66749256a24c94b228e7c9963f (patch) | |
tree | 52fc198527a67e0be06f7bfaad0c34c82d3d35d4 /test | |
parent | 41c81cf79d5318111ffa93e309bcafb149e6aa0e (diff) | |
download | yahns-e07ce2ae90195a66749256a24c94b228e7c9963f.tar.gz |
We need to be able to resume hijacking if gigantic HTTP headers are buffered on the response.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_output_buffering.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/test_output_buffering.rb b/test/test_output_buffering.rb index b6c7500..029b90c 100644 --- a/test/test_output_buffering.rb +++ b/test/test_output_buffering.rb @@ -281,5 +281,47 @@ class TestOutputBuffering < Testcase apperr.close! if apperr quit_wait(pid) end + + def test_hijacked + err, cfg, host, port = @err, Yahns::Config.new, @srv.addr[3], @srv.addr[1] + cfg.instance_eval do + ru = lambda do |e| + h = { + "Content-Type" => "text/plain", + "Content-Length" => "4", + "rack.hijack" => proc { |x| x.write("HIHI"); x.close }, + } + body = Object.new + def body.each; abort "body#each should not be used"; end + [ 200, BigHeader.new(h), body ] + end + GTL.synchronize do + app(:rack, ru) do + listen "#{host}:#{port}" + end + end + stderr_path err.path + end + pid = mkserver(cfg) + c = get_tcp_client(host, port) + c.write "GET / HTTP/1.0\r\n\r\n" + begin + sleep 1 + end while c.nread == 0 + nr = 0 + last = nil + c.each_line do |line| + case line + when %r{\AX-} then nr += 1 + else + last = line + end + end + assert_equal NR, nr + assert_equal "HIHI", last + c.close + ensure + quit_wait(pid) + end end if `which curl 2>/dev/null`.strip =~ /curl/ && `which md5sum 2>/dev/null`.strip =~ /md5sum/ |