diff options
author | Eric Wong <e@80x24.org> | 2016-10-30 21:10:44 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-10-30 21:10:44 +0000 |
commit | 1801e22f390549284892456edc1c3117d03e8cfd (patch) | |
tree | 764875855ab3cc1dd74b74e1017a34d35779f608 | |
parent | dde44f1570112ee95a7eb766105d988ce70f1278 (diff) | |
parent | d5fbbf547203061b1eaafbe80c4538a37fce5a34 (diff) | |
download | unicorn-1801e22f390549284892456edc1c3117d03e8cfd.tar.gz |
* origin/rfc2616-sec19.3: Add some tolerance (RFC2616 sec. 19.3)
-rw-r--r-- | ext/unicorn_http/unicorn_http_common.rl | 2 | ||||
-rw-r--r-- | test/unit/test_http_parser.rb | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/ext/unicorn_http/unicorn_http_common.rl b/ext/unicorn_http/unicorn_http_common.rl index cc1d455..0988b54 100644 --- a/ext/unicorn_http/unicorn_http_common.rl +++ b/ext/unicorn_http/unicorn_http_common.rl @@ -4,7 +4,7 @@ #### HTTP PROTOCOL GRAMMAR # line endings - CRLF = "\r\n"; + CRLF = ("\r\n" | "\n"); # character types CTL = (cntrl | 127); diff --git a/test/unit/test_http_parser.rb b/test/unit/test_http_parser.rb index c72f7f2..7cbc0f8 100644 --- a/test/unit/test_http_parser.rb +++ b/test/unit/test_http_parser.rb @@ -230,6 +230,24 @@ class HttpParserTest < Test::Unit::TestCase assert_equal expect, req['HTTP_X_SSL_BULLSHIT'] end + def test_multiline_header_0d0a + parser = HttpParser.new + parser.buf << "GET / HTTP/1.0\r\n" \ + "X-Multiline-Header: foo bar\r\n\tcha cha\r\n\tzha zha\r\n\r\n" + req = parser.env + assert_equal req, parser.parse + assert_equal 'foo bar cha cha zha zha', req['HTTP_X_MULTILINE_HEADER'] + end + + def test_multiline_header_0a + parser = HttpParser.new + parser.buf << "GET / HTTP/1.0\n" \ + "X-Multiline-Header: foo bar\n\tcha cha\n\tzha zha\n\n" + req = parser.env + assert_equal req, parser.parse + assert_equal 'foo bar cha cha zha zha', req['HTTP_X_MULTILINE_HEADER'] + end + def test_continuation_eats_leading_spaces parser = HttpParser.new header = "GET / HTTP/1.1\r\n" \ |