Skip to content

Fix false "Incomplete download" error with Content-Encoding#1693

Open
o1x3 wants to merge 1 commit intohttpie:masterfrom
o1x3:fix/download-content-encoding-1642
Open

Fix false "Incomplete download" error with Content-Encoding#1693
o1x3 wants to merge 1 commit intohttpie:masterfrom
o1x3:fix/download-content-encoding-1642

Conversation

@o1x3
Copy link

@o1x3 o1x3 commented Feb 5, 2026

When servers send Content-Encoding: gzip with --download, HTTPie reports "Incomplete download" even though the file downloads successfully. This happens because Content-Length reflects the compressed size, but requests auto-decompresses the response, so the downloaded bytes exceed Content-Length.

The fix changes the interrupted check from != to <. Now "received more bytes than expected" is treated as complete, not interrupted. This also preserves progress tracking (percentage display) which would be lost if we disabled size checking entirely.

Fixes #1642
See also #423

When servers send Content-Encoding: gzip, Content-Length reflects
compressed size, but requests auto-decompresses. This caused
downloaded bytes to exceed Content-Length, triggering false errors.

Changed interrupted check from `!=` to `<` so receiving more bytes
than expected is correctly treated as complete.

Fixes httpie#1642
See also httpie#423
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Bug Report: http --download misinterprets Content-Length when Content-Encoding: gzip is set

1 participant