-
Notifications
You must be signed in to change notification settings - Fork 286
Description
Description of issue or feature request:
If target is a gzip file, served with a Content-Encoding: gzip header, requests will automatically decode the file.
Current behavior:
As a result, the default fetcher for tuf ngclient raises a DownloadLengthMismatchError:
tuf.api.exceptions.DownloadLengthMismatchError: Downloaded x bytes exceeding the maximum allowed length of y
Expected behavior:
From the requests docs:
An important note about using
Response.iter_contentversusResponse.raw.Response.iter_contentwill automatically decode thegzipanddeflatetransfer-encodings.Response.rawis a raw stream of bytes – it does not transform the response content. If you really need access to the bytes as they were returned, useResponse.raw.
I would expect tuf to access the Reponse.raw instead of Response.iter_content here:
| for data in response.iter_content(self.chunk_size): |
Note that Response.raw is a urllib3.response.HTTPResponse, which also decodes gzip encoded content by default, but requests disables this by setting decode_content=False.