From 4b2782a926d8f131b1e7382be35e3abb77bf4be5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 7 Sep 2014 02:40:44 +0000 Subject: http: reduce parser from 72 to 56 bytes on 64-bit This allows the parser struct to fit in one cache line on x86-64 systems where cache lines are 64 bytes. Using 32-bit integer lengths is safe here because these are only for tracking offsets within the HTTP header buffer. We can safely limit HTTP headers and in-memory buffers to be less than 4GB without anybody complaining. HTTP bodies continue to use off_t (usually 64-bit, even on 32-bit systems) sizes and support as much as the OS/hardware can handle. --- test/unit/test_http_parser_ng.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test') diff --git a/test/unit/test_http_parser_ng.rb b/test/unit/test_http_parser_ng.rb index 9167845..d5c8d2e 100644 --- a/test/unit/test_http_parser_ng.rb +++ b/test/unit/test_http_parser_ng.rb @@ -11,6 +11,12 @@ class HttpParserNgTest < Test::Unit::TestCase @parser = HttpParser.new end + def test_parser_max_len + assert_raises(RangeError) do + HttpParser.max_header_len = 0xffffffff + 1 + end + end + def test_next_clear r = "GET / HTTP/1.1\r\nHost: example.com\r\n\r\n" @parser.buf << r -- cgit v1.2.3-24-ge0c7