diff --git a/.gitmodules b/.gitmodules index 52392af..85c6ce7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,4 @@ [submodule "vendor/llhttp"] path = vendor/llhttp url = https://github.com/nodejs/llhttp.git + branch = release diff --git a/tests/test_parser.py b/tests/test_parser.py index 8cce866..a169a9a 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -16,7 +16,7 @@ Accept-Ranges: bytes Connection: close -''' +'''.replace(b'\n', b'\r\n') RESPONSE1_BODY = b''' @@ -29,31 +29,31 @@ ''' -CHUNKED_REQUEST1_1 = b'''POST /test.php?a=b+c HTTP/1.2 -User-Agent: Fooo -Host: bar -Transfer-Encoding: chunked +CHUNKED_REQUEST1_1 = b'''POST /test.php?a=b+c HTTP/1.1\r +User-Agent: Fooo\r +Host: bar\r +Transfer-Encoding: chunked\r 5\r\nhello\r\n6\r\n world\r\n''' CHUNKED_REQUEST1_2 = b'''0\r\nVary: *\r\nUser-Agent: spam\r\n\r\n''' -CHUNKED_REQUEST1_3 = b'''POST /test.php?a=b+c HTTP/1.2 -User-Agent: Fooo -Host: bar -Transfer-Encoding: chunked +CHUNKED_REQUEST1_3 = b'''POST /test.php?a=b+c HTTP/1.1\r +User-Agent: Fooo\r +Host: bar\r +Transfer-Encoding: chunked\r b\r\n+\xce\xcfM\xb5MI,I\x04\x00\r\n0\r\n\r\n''' -UPGRADE_REQUEST1 = b'''GET /demo HTTP/1.1 -Host: example.com -Connection: Upgrade -Sec-WebSocket-Key2: 12998 5 Y3 1 .P00 -Sec-WebSocket-Protocol: sample -Upgrade: WebSocket -Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5 -Origin: http://example.com +UPGRADE_REQUEST1 = b'''GET /demo HTTP/1.1\r +Host: example.com\r +Connection: Upgrade\r +Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r +Sec-WebSocket-Protocol: sample\r +Upgrade: WebSocket\r +Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r +Origin: http://example.com\r Hot diggity dogg''' @@ -233,7 +233,7 @@ def test_parser_request_chunked_1(self): m.on_message_begin.assert_called_once_with() m.on_url.assert_called_once_with(b'/test.php?a=b+c') - self.assertEqual(p.get_http_version(), '1.2') + self.assertEqual(p.get_http_version(), '1.1') m.on_header.assert_called_with(b'Transfer-Encoding', b'chunked') m.on_chunk_header.assert_called_with() @@ -316,7 +316,7 @@ def test_parser_request_chunked_3(self): self.assertEqual(p.get_method(), b'POST') m.on_url.assert_called_once_with(b'/test.php?a=b+c') - self.assertEqual(p.get_http_version(), '1.2') + self.assertEqual(p.get_http_version(), '1.1') m.on_header.assert_called_with(b'Transfer-Encoding', b'chunked') m.on_chunk_header.assert_called_with() @@ -439,17 +439,17 @@ class Error(Exception): def test_parser_request_2(self): p = httptools.HttpRequestParser(None) with self.assertRaises(httptools.HttpParserInvalidMethodError): - p.feed_data(b'SPAM /test.php?a=b+c HTTP/1.2') + p.feed_data(b'SPAM /test.php?a=b+c HTTP/1.1') def test_parser_request_3(self): p = httptools.HttpRequestParser(None) with self.assertRaises(httptools.HttpParserInvalidURLError): - p.feed_data(b'POST HTTP/1.2') + p.feed_data(b'POST HTTP/1.1') def test_parser_request_4(self): p = httptools.HttpRequestParser(None) with self.assertRaisesRegex(TypeError, 'a bytes-like object'): - p.feed_data('POST HTTP/1.2') + p.feed_data('POST HTTP/1.1') def test_parser_request_fragmented(self): m = mock.Mock() diff --git a/vendor/llhttp b/vendor/llhttp index 4bfeb62..6d954cb 160000 --- a/vendor/llhttp +++ b/vendor/llhttp @@ -1 +1 @@ -Subproject commit 4bfeb625ce4961bd539c95593529936503be7db4 +Subproject commit 6d954cbdc7f641f0a63a4427cf4d6be397f74ee8