Collapse request chunked data and framing into one send() call
MODIFY
src/urllib3/connection.py
src/urllib3/connection.py
@@ -240,10 +240,11 @@ class HTTPConnection(_HTTPConnection, object):
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")

Collapse request chunked data and framing into one send() call (#1906)