diff options
author | Eric Wong <normalperson@yhbt.net> | 2012-03-03 10:38:55 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2012-03-03 10:38:55 +0000 |
commit | 7f99c180d0b9db55e2984721f96b93f28fc5757b (patch) | |
tree | 39144b5a9d9c179906bf8cf4966fdac729449b18 /test/http.rb | |
parent | e9fada6db32ad1f2402e5993c6eb6fec55d4c174 (diff) | |
download | cmogstored-7f99c180d0b9db55e2984721f96b93f28fc5757b.tar.gz |
Some folks with reproxy setups end up forwarding large headers (e.g. session cookies) to mogstored backends. Since our per-client HTTP buffer offsets are uint16_t, UINT16_MAX was chosen. Perlbal actually allows 100K, but I doubt anybody would ever actually need that much.
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 |