Skip to content
Myr

Update urllib3 to 7b82da0fa3a13514d11a863e379e7541d0ec46ef

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

authored by Ian Cordasco · committed by Ian Cordasco · parent 3880cf1 · Browse files · 1 file+34 added−18 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+34 added−18 removed

  • other:+34 added−18 removed

1 file+34 added−18 removed

modified:requests/packages/urllib3/response.py+34 added-18 removed
170 unmodified lines
171 are encoded on the wire (e.g, compressed).172 """173 return self._fp_bytes_read174175 def _init_decoder(self):176 """177 Set-up the _decoder attribute if necessar.178 """179 # Note: content-encoding value should be case-insensitive, per RFC 7230180 # Section 3.2181 content_encoding = self.headers.get('content-encoding', '').lower()182 if self._decoder is None:183 if content_encoding in self.CONTENT_DECODERS:184 self._decoder = _get_decoder(content_encoding)185186 def _decode(self, data, decode_content, flush_decoder):187 """188 Decode the data passed in and potentially flush the decoder.189 """190 try:191 if decode_content and self._decoder:192 data = self._decoder.decompress(data)193 except (IOError, zlib.error) as e:194 content_encoding = self.headers.get('content-encoding', '').lower()195 raise DecodeError(196 "Received response with content-encoding: %s, but "197 "failed to decode it." % content_encoding, e)198199 if flush_decoder and decode_content and self._decoder:200 buf = self._decoder.decompress(binary_type())201 data += buf + self._decoder.flush()202203 return data204205 def read(self, amt=None, decode_content=None, cache_content=False):206 """207 Similar to :meth:`httplib.HTTPResponse.read`, but with two additional208 parameters: ``decode_content`` and ``cache_content``.
13 unmodified lines
222 is useful if you want the ``.data`` property to continue working223 after having ``.read()`` the file object. (Overridden if ``amt`` is224 set.)225 """196 # Note: content-encoding value should be case-insensitive, per RFC 7230197 # Section 3.2198 content_encoding = self.headers.get('content-encoding', '').lower()199 if self._decoder is None:200 if content_encoding in self.CONTENT_DECODERS:201 self._decoder = _get_decoder(content_encoding)226 self._init_decoder()227 if decode_content is None:228 decode_content = self.decode_content229230 if self._fp is None:
40 unmodified lines
271 raise ProtocolError('Connection broken: %r' % e, e)272273 self._fp_bytes_read += len(data)274250 try:251 if decode_content and self._decoder:252 data = self._decoder.decompress(data)253 except (IOError, zlib.error) as e:254 raise DecodeError(255 "Received response with content-encoding: %s, but "256 "failed to decode it." % content_encoding, e)275 data = self._decode(data, decode_content, flush_decoder)276258 if flush_decoder and decode_content and self._decoder:259 buf = self._decoder.decompress(binary_type())260 data += buf + self._decoder.flush()261277 if cache_content:278 self._body = data279280 return data
17 unmodified lines
298 :param decode_content:299 If True, will attempt to decode the body based on the300 'content-encoding' header.301 """302 self._init_decoder()303 if self.chunked:304 for line in self.read_chunked(amt):289 yield line305 yield self._decode(line, decode_content, True)306 else:307 while not is_fp_closed(self._fp):308 data = self.read(amt=amt, decode_content=decode_content)309
135 unmodified lines