10000 Add support for buffering kwarg in urllib3. · github3py/urllib3@d9c9714 · GitHub
[go: up one dir, main page]

Skip to content

Commit d9c9714

Browse files
author
Philip K. Warren
committed
Add support for buffering kwarg in urllib3.
1 parent ea448f9 commit d9c9714

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

urllib3/connectionpool.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def __init__(self, host, port=None, strict=False, timeout=None, maxsize=1,
172172
self.pool = self.QueueCls(maxsize)
173173
self.block = block
174174
self.headers = headers or {}
175+
self._buffering = True
175176

176177
# Fill the queue up so that doing get() on it will block properly
177178
for _ in xrange(maxsize):
@@ -258,7 +259,15 @@ def _make_request(self, conn, method, url, timeout=_Default,
258259
if sock:
259260
sock.settimeout(timeout)
260261

261-
httplib_response = conn.getresponse()
262+
if self._buffering:
263+
try:
264+
httplib_response = conn.getresponse(buffering=True)
265+
except TypeError:
266+
# Don't try buffering again - kwarg not supported
267+
self._buffering = False
268+
httplib_response = conn.getresponse()
269+
else:
270+
httplib_response = conn.getresponse()
262271

263272
# AppEngine doesn't have a version attr.
264273
http_version = getattr(conn, '_http_vsn_str', 'HTTP/?'),

0 commit comments

Comments
 (0)
0