Permalink
Browse files

StringIO and BytesIO have different names for the `length` attribute

  • Loading branch information...
1 parent 0143b41 commit 3837b8874acf4c310849288876ee2b6765f815ff @singingwolfboy singingwolfboy committed Mar 16, 2012
Showing with 7 additions and 1 deletion.
  1. +7 −1 requests/packages/urllib3/connectionpool.py
@@ -264,10 +264,16 @@ def _make_request(self, conn, method, url, timeout=_Default,
conn.sock.settimeout(timeout)
httplib_response = conn.getresponse()
+ if hasattr(httplib_response, "length"):
+ resp_length = httplib_response.length
+ elif hasattr(httplib_response, "len"):
+ resp_length = httplib_response.len
+ else:
+ resp_length = 0
log.debug("\"%s %s %s\" %s %s" %
(method, url,
getattr(conn, "_http_vsn_str", ""), # pylint: disable-msg=W0212
- httplib_response.status, httplib_response.length))
+ httplib_response.status, resp_length))
return httplib_response

0 comments on commit 3837b88

Please sign in to comment.