Skip to content

Commit

Permalink
Update llhttp to version 6.0.9 (#83)
Browse files Browse the repository at this point in the history
pls note that CRLF delimited headers are required (per HTTP spec also) since the 6.0.7 security update of NodeJS / llhttp
  • Loading branch information
nlsj1985 committed Sep 13, 2022
1 parent bbc3791 commit 56d6a16
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
[submodule "vendor/llhttp"]
path = vendor/llhttp
url = https://github.com/nodejs/llhttp.git
branch = release
44 changes: 22 additions & 22 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Accept-Ranges: bytes
Connection: close
'''
'''.replace(b'\n', b'\r\n')

RESPONSE1_BODY = b'''
<html>
Expand All @@ -29,31 +29,31 @@
</html>'''


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'''

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion vendor/llhttp
Submodule llhttp updated 7 files
+89 −27 CMakeLists.txt
+34 −2 README.md
+19 −6 include/llhttp.h
+10 −0 libllhttp.pc.in
+8 −0 src/api.c
+2 −1 src/http.c
+1,173 −411 src/llhttp.c

0 comments on commit 56d6a16

Please sign in to comment.