Skip to content

Commit

Permalink
[1.25] Collapse request chunked data and framing into one send() call (
Browse files Browse the repository at this point in the history
  • Loading branch information
sethmlarson committed Jul 19, 2020
1 parent 187dfc2 commit 2512014
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/urllib3/connection.py
Expand Up @@ -225,10 +225,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 2512014

Please sign in to comment.