mirror of
https://github.com/httpie/cli.git
synced 2025-01-23 13:58:45 +01:00
Correctly handle single-byte Content-Range (#1032)
HTTPie previously failed if it continued a download with a single byte left.
This commit is contained in:
parent
e944dbd7fa
commit
84c7327057
@ -81,7 +81,7 @@ def parse_content_range(content_range: str, resumed_from: int) -> int:
|
||||
# last-byte-pos value, is invalid. The recipient of an invalid
|
||||
# byte-content-range- spec MUST ignore it and any content
|
||||
# transferred along with it."
|
||||
if (first_byte_pos >= last_byte_pos
|
||||
if (first_byte_pos > last_byte_pos
|
||||
or (instance_length is not None
|
||||
and instance_length <= last_byte_pos)):
|
||||
raise ContentRangeError(
|
||||
|
@ -30,6 +30,9 @@ class TestDownloadUtils:
|
||||
assert parse('bytes 100-199/200', 100) == 200
|
||||
assert parse('bytes 100-199/*', 100) == 200
|
||||
|
||||
# single byte
|
||||
assert parse('bytes 100-100/*', 100) == 101
|
||||
|
||||
# missing
|
||||
pytest.raises(ContentRangeError, parse, None, 100)
|
||||
|
||||
@ -45,9 +48,6 @@ class TestDownloadUtils:
|
||||
# invalid byte-range-resp-spec
|
||||
pytest.raises(ContentRangeError, parse, 'bytes 100-99/199', 100)
|
||||
|
||||
# invalid byte-range-resp-spec
|
||||
pytest.raises(ContentRangeError, parse, 'bytes 100-100/*', 100)
|
||||
|
||||
@pytest.mark.parametrize('header, expected_filename', [
|
||||
('attachment; filename=hello-WORLD_123.txt', 'hello-WORLD_123.txt'),
|
||||
('attachment; filename=".hello-WORLD_123.txt"', 'hello-WORLD_123.txt'),
|
||||
|
Loading…
Reference in New Issue
Block a user