@@ -136,13 +136,10 @@ def _write_to_stream(self, response):
136136 if self .single_shot_download :
137137 # This is useful for smaller files, or when the user wants to
138138 # download the entire file in one go.
139- content = response .raw .read ()
139+ content = response .raw .read (decode_content = True )
140140 self ._stream .write (content )
141141 self ._bytes_downloaded += len (content )
142- if isinstance (local_checksum_object , _helpers ._DoNothingHash ):
143- checksum_object .update (content )
144- else :
145- local_checksum_object .update (content )
142+ local_checksum_object .update (content )
146143 response ._content_consumed = True
147144 else :
148145 body_iter = response .iter_content (
@@ -699,6 +696,23 @@ def _add_decoder(response_raw, checksum):
699696 return checksum
700697
701698
699+ # def _get_decoded_content(raw_content):
700+ # """Get the decoded content from a raw response.
701+
702+ # Args:
703+ # raw_content (bytes): The raw bytes from the response.
704+
705+ # Returns:
706+ # bytes: The decoded bytes from ``raw_content``.
707+ # """
708+ # # If the content is gzip-encoded, decode it.
709+ # if raw_content.headers.get("content-encoding", "").lower() == "gzip":
710+ # return raw_content.read(decode_content=True)
711+ # else:
712+ # return raw_content.read() # type: ignore
713+
714+
715+
702716class _GzipDecoder (urllib3 .response .GzipDecoder ):
703717 """Custom subclass of ``urllib3`` decoder for ``gzip``-ed bytes.
704718
0 commit comments