Decode HTTP responses, fixes bug #1282861
By default, the HTTPConnection class expose the raw.read urllib3 function which doesn't do any decoding on the http response. We can fix this by passing decode_content=True to raw.read(). Change-Id: I7d42d31ae516705d1bde2769e642931308116c7a
This commit is contained in:
parent
d721dc7b61
commit
bffdadee57
@ -22,6 +22,7 @@ import requests
|
|||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import warnings
|
import warnings
|
||||||
|
import functools
|
||||||
|
|
||||||
from distutils.version import StrictVersion
|
from distutils.version import StrictVersion
|
||||||
from requests.exceptions import RequestException, SSLError
|
from requests.exceptions import RequestException, SSLError
|
||||||
@ -210,7 +211,8 @@ class HTTPConnection:
|
|||||||
|
|
||||||
self.resp.getheaders = getheaders
|
self.resp.getheaders = getheaders
|
||||||
self.resp.getheader = getheader
|
self.resp.getheader = getheader
|
||||||
self.resp.read = self.resp.raw.read
|
self.resp.read = functools.partial(self.resp.raw.read,
|
||||||
|
decode_content=True)
|
||||||
return self.resp
|
return self.resp
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user