Skip to content

Commit

Permalink
Collapse request chunked data and framing into one send() call (urlli…
Browse files Browse the repository at this point in the history
  • Loading branch information
sethmlarson committed Jul 16, 2020
1 parent 06757ce commit f5283c9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/urllib3/connection.py
Expand Up @@ -240,10 +240,11 @@ def request_chunked(self, method, url, body=None, headers=None):
if not isinstance(chunk, bytes):
chunk = chunk.encode("utf8")
len_str = hex(len(chunk))[2:]
self.send(len_str.encode("utf-8"))
self.send(b"\r\n")
self.send(chunk)
self.send(b"\r\n")
to_send = bytearray(len_str.encode())
to_send += b"\r\n"
to_send += chunk
to_send += b"\r\n"
self.send(to_send)

# After the if clause, to always have a closed body
self.send(b"0\r\n\r\n")
Expand Down

0 comments on commit f5283c9

Please sign in to comment.