mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Handle empty chunks
Empty chunk in request body could prematurely signal end of chunked transmission. As a result, the terminating zero-size chunk sent by 'requests' can be interpretted as bad request by the recepient. We ignore such empty chunks.
This commit is contained in:
committed by
Sabari Kumar Murugesan
parent
bd3cf95e34
commit
038b61477c
@@ -388,7 +388,10 @@ class HTTPAdapter(BaseAdapter):
|
||||
low_conn.endheaders()
|
||||
|
||||
for i in request.body:
|
||||
low_conn.send(hex(len(i))[2:].encode('utf-8'))
|
||||
chunk_size = len(i)
|
||||
if chunk_size == 0:
|
||||
continue
|
||||
low_conn.send(hex(chunk_size)[2:].encode('utf-8'))
|
||||
low_conn.send(b'\r\n')
|
||||
low_conn.send(i)
|
||||
low_conn.send(b'\r\n')
|
||||
|
||||
Reference in New Issue
Block a user