Skip to content

Commit

Permalink
StringIO and BytesIO have different names for the length attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
singingwolfboy committed Mar 16, 2012
1 parent 0143b41 commit 3837b88
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion requests/packages/urllib3/connectionpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3837b88

Please sign in to comment.