barneygale / httpio

Python library for reading HTTP resources as random-access file-like objects using the `Range` header
Other
31 stars 5 forks source link

"httpio.HTTPIOError: Server does not accept 'Range' headers" when server does accept Range #6

Open ewjoachim opened 4 years ago

ewjoachim commented 4 years ago

For some reason, it seems AmazonS3 may return the "accept-ranges: bytes" header more than once. requests will concatenate the values, resulting in the header value being bytes, bytes, and then:

https://github.com/barneygale/httpio/blob/18c1b98e3b36156477124139afa234800fc24634/httpio/__init__.py#L70

This test triggers, and we can't open the file.

I'd guess a better test would be "bytes" in response.headers.get(...)

Also, it looks like the Accept-Ranges header is not required: https://tools.ietf.org/html/rfc7233#section-2.3

An origin server that supports byte-range requests for a given target resource MAY send Accept-Ranges: bytes to indicate what range units are supported.

Here's an url you can try for reproduction https://files.pythonhosted.org/packages/44/e8/4ae9ef3d455f4ce5aa22259cb6e40c69b29ef6b02d49c5cdfa265f7fc821/Django-3.0.1.tar.gz