Skip to content
Myr

Use buffering for HTTP responses on chunked requests

Before adoption: this commit came in with the history the project adopted, so no landing records it.

For non-chunked requests, the request is performed using the 'urlopen' method that underlying uses buffering for the HTTP responses (for Python 2.7+ versions). For chunked requests though, the request is made via a different code path and so the 'getresponse' method is called without using buffering. So, the response is consumed per single byte via a recv() call on the underlying socket. This patch, fixes that issue to mimic the non-chucked request behavior.

authored by Dimitris Bliablias · committed by Dimitris Bliablias · parent 6c2d09d · Browse files · 1 file+9 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−1 removed

  • other:+9 added−1 removed

1 file+9 added−1 removed

modified:requests/adapters.py+9 added-1 removed
392 unmodified lines
393 low_conn.send(i)394 low_conn.send(b'\r\n')395 low_conn.send(b'0\r\n\r\n')396397 # Receive the response from the server398 try:399 # For Python 2.7+ versions, use buffering of HTTP400 # responses401 r = conn.getresponse(buffering=True)402 except TypeError:403 # For compatibility with Python 2.6 versions and back397 r = low_conn.getresponse()404 r = conn.getresponse()405406 resp = HTTPResponse.from_httplib(407 r,408 pool=conn,409 connection=low_conn,
38 unmodified lines