Skip to content

Commit 56d6a16

Browse files
authored
Update llhttp to version 6.0.9 (#83)
pls note that CRLF delimited headers are required (per HTTP spec also) since the 6.0.7 security update of NodeJS / llhttp
1 parent bbc3791 commit 56d6a16

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed

.gitmodules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
[submodule "vendor/llhttp"]
55
path = vendor/llhttp
66
url = https://github.com/nodejs/llhttp.git
7+
branch = release

tests/test_parser.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Accept-Ranges: bytes
1717
Connection: close
1818
19-
'''
19+
'''.replace(b'\n', b'\r\n')
2020

2121
RESPONSE1_BODY = b'''
2222
<html>
@@ -29,31 +29,31 @@
2929
</html>'''
3030

3131

32-
CHUNKED_REQUEST1_1 = b'''POST /test.php?a=b+c HTTP/1.2
33-
User-Agent: Fooo
34-
Host: bar
35-
Transfer-Encoding: chunked
32+
CHUNKED_REQUEST1_1 = b'''POST /test.php?a=b+c HTTP/1.1\r
33+
User-Agent: Fooo\r
34+
Host: bar\r
35+
Transfer-Encoding: chunked\r
3636
3737
5\r\nhello\r\n6\r\n world\r\n'''
3838

3939
CHUNKED_REQUEST1_2 = b'''0\r\nVary: *\r\nUser-Agent: spam\r\n\r\n'''
4040

41-
CHUNKED_REQUEST1_3 = b'''POST /test.php?a=b+c HTTP/1.2
42-
User-Agent: Fooo
43-
Host: bar
44-
Transfer-Encoding: chunked
41+
CHUNKED_REQUEST1_3 = b'''POST /test.php?a=b+c HTTP/1.1\r
42+
User-Agent: Fooo\r
43+
Host: bar\r
44+
Transfer-Encoding: chunked\r
4545
4646
b\r\n+\xce\xcfM\xb5MI,I\x04\x00\r\n0\r\n\r\n'''
4747

4848

49-
UPGRADE_REQUEST1 = b'''GET /demo HTTP/1.1
50-
Host: example.com
51-
Connection: Upgrade
52-
Sec-WebSocket-Key2: 12998 5 Y3 1 .P00
53-
Sec-WebSocket-Protocol: sample
54-
Upgrade: WebSocket
55-
Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5
56-
Origin: http://example.com
49+
UPGRADE_REQUEST1 = b'''GET /demo HTTP/1.1\r
50+
Host: example.com\r
51+
Connection: Upgrade\r
52+
Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r
53+
Sec-WebSocket-Protocol: sample\r
54+
Upgrade: WebSocket\r
55+
Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r
56+
Origin: http://example.com\r
5757
5858
Hot diggity dogg'''
5959

@@ -233,7 +233,7 @@ def test_parser_request_chunked_1(self):
233233
m.on_message_begin.assert_called_once_with()
234234

235235
m.on_url.assert_called_once_with(b'/test.php?a=b+c')
236-
self.assertEqual(p.get_http_version(), '1.2')
236+
self.assertEqual(p.get_http_version(), '1.1')
237237

238238
m.on_header.assert_called_with(b'Transfer-Encoding', b'chunked')
239239
m.on_chunk_header.assert_called_with()
@@ -316,7 +316,7 @@ def test_parser_request_chunked_3(self):
316316
self.assertEqual(p.get_method(), b'POST')
317317

318318
m.on_url.assert_called_once_with(b'/test.php?a=b+c')
319-
self.assertEqual(p.get_http_version(), '1.2')
319+
self.assertEqual(p.get_http_version(), '1.1')
320320

321321
m.on_header.assert_called_with(b'Transfer-Encoding', b'chunked')
322322
m.on_chunk_header.assert_called_with()
@@ -439,17 +439,17 @@ class Error(Exception):
439439
def test_parser_request_2(self):
440440
p = httptools.HttpRequestParser(None)
441441
with self.assertRaises(httptools.HttpParserInvalidMethodError):
442-
p.feed_data(b'SPAM /test.php?a=b+c HTTP/1.2')
442+
p.feed_data(b'SPAM /test.php?a=b+c HTTP/1.1')
443443

444444
def test_parser_request_3(self):
445445
p = httptools.HttpRequestParser(None)
446446
with self.assertRaises(httptools.HttpParserInvalidURLError):
447-
p.feed_data(b'POST HTTP/1.2')
447+
p.feed_data(b'POST HTTP/1.1')
448448

449449
def test_parser_request_4(self):
450450
p = httptools.HttpRequestParser(None)
451451
with self.assertRaisesRegex(TypeError, 'a bytes-like object'):
452-
p.feed_data('POST HTTP/1.2')
452+
p.feed_data('POST HTTP/1.1')
453453

454454
def test_parser_request_fragmented(self):
455455
m = mock.Mock()

0 commit comments

Comments
 (0)