Skip to content

Commit 884bed1

Browse files
Update tests to remove invalid chunked encoding chunk-size
RFC7230 states the following: chunk = chunk-size [ chunk-ext ] CRLF chunk-data CRLF chunk-size = 1*HEXDIG Where chunk-ext is: chunk-ext = *( ";" chunk-ext-name [ "=" chunk-ext-val ] ) Only if there is a chunk-ext should there be a `;` after the 1*HEXDIG. And a chunk-ext that is empty is invalid.
1 parent 1f6059f commit 884bed1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tests/test_functional.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def test_chunking_request_without_content(self):
322322
self.assertFalse("transfer-encoding" in headers)
323323

324324
def test_chunking_request_with_content(self):
325-
control_line = b"20;\r\n" # 20 hex = 32 dec
325+
control_line = b"20\r\n" # 20 hex = 32 dec
326326
s = b"This string has 32 characters.\r\n"
327327
expected = s * 12
328328
header = b"GET / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n"
@@ -341,7 +341,7 @@ def test_chunking_request_with_content(self):
341341
self.assertFalse("transfer-encoding" in headers)
342342

343343
def test_broken_chunked_encoding(self):
344-
control_line = b"20;\r\n" # 20 hex = 32 dec
344+
control_line = b"20\r\n" # 20 hex = 32 dec
345345
s = b"This string has 32 characters.\r\n"
346346
to_send = b"GET / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n"
347347
to_send += control_line + s + b"\r\n"
@@ -365,7 +365,7 @@ def test_broken_chunked_encoding(self):
365365
self.assertRaises(ConnectionClosed, read_http, fp)
366366

367367
def test_broken_chunked_encoding_missing_chunk_end(self):
368-
control_line = b"20;\r\n" # 20 hex = 32 dec
368+
control_line = b"20\r\n" # 20 hex = 32 dec
369369
s = b"This string has 32 characters.\r\n"
370370
to_send = b"GET / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n"
371371
to_send += control_line + s

tests/test_parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def test_received_chunked_completed_sets_content_length(self):
155155
b"Transfer-Encoding: chunked\r\n"
156156
b"X-Foo: 1\r\n"
157157
b"\r\n"
158-
b"1d;\r\n"
158+
b"1d\r\n"
159159
b"This string has 29 characters\r\n"
160160
b"0\r\n\r\n"
161161
)

0 commit comments

Comments
 (0)