Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes/supports raw mode of Deflate compression.
Details
When request with
Accept-Encoding: deflateHTTP header, some CDNs may have an unusual behavior, which responds with the content compressed in raw Deflate mode withContent-Encoding: deflateheader. This causes aria2 abort download with error messagelibz::inflate() failed. cause:incorrect header check.As zlib Manual described:
This PR tries to fix this issue by try decompress the content twice. The first trial is in normal mode, which is same as the old behavior. If the first trial fails, it will try re-initialiaze
GZipDecodingStreamFilterclass withwindowBits = -15. Then, if the second trial is failed, aria2 will abort download, same as the old behavior.Related URLs / Issues
Test Result
On my laptop the fix passed test with
make -j2 check:However, a new test file compressed in raw Deflate mode might be needed to add more coverage to this case. Please reach me if I need further actions.