Open njsmith opened 5 years ago
It looks like urllib3 uses:
REDIRECT_STATUSES = [301, 302, 303, 307, 308]
Yeah I'm working on a branch here dealing with redirects at the moment. There's...a bit of debt to be paid.
Ty for report :D
I hear ya...
I've just been bitten by this. No progress yet?
Sorry. New position and swamped lately. If you've time happy to take a pr, should be simple. I can get to it Sunday if not.
Updates?
It looks like asks assumes that all 3xx responses are redirects, and should have Location: headers. But 304 Not Modified isn't a redirect. It happens when the requester uses some headers like
If-Modified-Since
orIf-None-Match
to tell the server that they already have a local copy, and the server is saying "yep, that local copy you have is still good, you should just use that".Right now, when this happens, asks raises a
KeyError
exception because it tries to look upresponse_obj.headers["Location"]
, but it's not there.I think the right thing to do is to treat 304 like a normal successful response, and just return it unchanged to the user. If they're using cache headers, then they're presumably prepared to handle this response.