diff options
Diffstat (limited to 'test/http.rb')
-rw-r--r-- | test/http.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/http.rb b/test/http.rb index ad21af4..c4d56a6 100644 --- a/test/http.rb +++ b/test/http.rb @@ -176,4 +176,33 @@ class TestHTTP < Test::Unit::TestCase assert_match(%r{\AHTTP/1\.1 400 Bad Request\r\n}, buf) assert_nil(@client.read(666)) end + + def test_monster_headers + buf = "GET /hello-world HTTP/1.1\r\n" + 4094.times { buf << "X-Hello: World\r\n" } + buf << "\r\n" + assert_operator(buf.bytesize, :<, 0xffff) + buf.each_line do |line| + @client.write(line) + sleep 0.000666 + end + buf = @client.readpartial(666) + assert_match %r{\AHTTP/1\.1 404 Not Found\r\n}, buf + end + + def test_large_request_rejected + buf = "GET /hello-world HTTP/1.1\r\n" + 4095.times { buf << "X-Hello: World\r\n" } + buf << "\r\n" + assert_operator(buf.bytesize, :>=, 0xffff) + begin + buf.each_line do |line| + @client.write(line) + sleep 0.000666 + end + rescue Errno::ECONNRESET + end + buf = @client.readpartial(666) + assert_match %r{\AHTTP/1\.1 400 Bad Request\r\n}, buf + end end |