I'm having the same problem. The server I'm downloading from supports the Range
header. Using requests
, the header is ignored and the entire file is downloaded with a 200
status code. Meanwhile, sending the request via urllib3
correctly returns the partial content with a 206
status code.
I suppose this must be some kind of bug or incompatibility. requests
works fine with other files, including the one in the example below. Accessing my file requires basic authorization - perhaps that has something to do with it?
If you run into this, urllib3
may be worth trying. You'll already have it because requests
uses it. This is how I worked around my problem:
import urllib3
url = "https://www.rfc-editor.org/rfc/rfc2822.txt"
http = urllib3.PoolManager()
response = http.request('GET', url, headers={'Range':'bytes=0-100'})
Update: I tried sending a Range
header to https://stackoverflow.com/
, which is the link you specified. This returns the entire content with both Python modules as well as curl, despite the response header specifying accept-ranges: bytes
. I can't say why.