* [PATCH] test/test_rack_hijack.rb: expensive giant header test
@ 2016-04-26 1:51 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2016-04-26 1:51 UTC (permalink / raw)
To: spew
Ugh, it's hard to test this. Probably not worth
pushing out to master.
---
test/test_rack_hijack.rb | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/test/test_rack_hijack.rb b/test/test_rack_hijack.rb
index 671387e..118e69b 100644
--- a/test/test_rack_hijack.rb
+++ b/test/test_rack_hijack.rb
@@ -9,6 +9,15 @@ class TestRackHijack < Testcase
alias setup server_helper_setup
alias teardown server_helper_teardown
+ class GiganticHeader
+ def each
+ yield('Transfer-Encoding', 'chunked')
+ yield('rack.hijack', lambda { |x| DieIfUsed.new })
+ junk_str = 'a' * 16384
+ 1_000.times { |i| yield("X-Junk-#{i}", junk_str) }
+ end
+ end
+
HIJACK_APP = lambda { |env|
case env["PATH_INFO"]
when "/hijack_input"
@@ -39,6 +48,8 @@ class TestRackHijack < Testcase
},
DieIfUsed.new
]
+ when '/hijack_res_giant'
+ [ 200, GiganticHeader.new, DieIfUsed.new ]
end
}
@@ -86,6 +97,22 @@ def test_hijack
assert_equal "rack.input contents: BLAH", res.body
assert_equal 201, res.code.to_i
assert_equal "1.0", res.http_version
+
+ Timeout.timeout(300) do
+ c = TCPSocket.new(host, port)
+ c.setsockopt(:SOL_SOCKET, :SO_RCVBUF, 8192)
+ c.write("GET /hijack_res_giant HTTP/1.1\r\n")
+ c.write("Host: example.com\r\n\r\n")
+ wait_for_full(c)
+ sleep 5
+ c.close
+ if RUBY_PLATFORM =~ /linux/ && `which lsof 2>/dev/null` =~ %r{/lsof$}
+ sleep 0.15
+ lsof = `lsof -p #{pid}`.split("\n")
+ assert_nil lsof.grep(/identify protocol/)[0], lsof.inspect
+ assert_nil lsof.grep(/\bREG\b/).grep(/\(deleted\)/)[0], lsof.inspect
+ end
+ end
ensure
quit_wait(pid)
end
--
EW
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-04-26 1:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-26 1:51 [PATCH] test/test_rack_hijack.rb: expensive giant header test Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).