Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly handle single-byte Content-Range #1032

Merged
merged 1 commit into from
Feb 14, 2021

Conversation

blyxxyz
Copy link
Contributor

@blyxxyz blyxxyz commented Feb 13, 2021

HTTPie fails if it continues a download with a single byte left. For example:

$ http -b -d example.org
Downloading 1.23 kB to "index.html"
Done. 1.23 kB in 0.00043s (2.81 MB/s)
$ python3 -c 'import sys; sys.stdout.write(open("index.html").read()[:-1])' > index-short.html
$ http -b -d -c -o index-short.html example.org

http: error: ContentRangeError: Invalid Content-Range returned: 'bytes 1255-1255/1256'

The range is inclusive on both ends.

@codecov-io
Copy link

Codecov Report

Merging #1032 (fc7c396) into master (e944dbd) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1032   +/-   ##
=======================================
  Coverage   95.58%   95.58%           
=======================================
  Files          61       61           
  Lines        3967     3967           
=======================================
  Hits         3792     3792           
  Misses        175      175           
Impacted Files Coverage Δ
httpie/downloads.py 91.22% <100.00%> (ø)
tests/test_downloads.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e944dbd...fc7c396. Read the comment docs.

@jkbrzt jkbrzt merged commit 84c7327 into httpie:master Feb 14, 2021
@jkbrzt
Copy link
Member

jkbrzt commented Feb 14, 2021

@blyxxyz good catch. Thanks for the PR and test! 🥧

@blyxxyz blyxxyz deleted the one-byte-content-range branch February 14, 2021 12:32
jkbrzt added a commit that referenced this pull request Feb 14, 2021
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.

3 participants