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

asks crashes on a 304 Not Modified response #133

Open
njsmith opened this issue Aug 16, 2019 · 6 comments
Open

asks crashes on a 304 Not Modified response #133

njsmith opened this issue Aug 16, 2019 · 6 comments

Comments

@njsmith
Copy link
Contributor

njsmith commented Aug 16, 2019

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 or If-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 up response_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.

@njsmith
Copy link
Contributor Author

njsmith commented Aug 16, 2019

It looks like urllib3 uses:

    REDIRECT_STATUSES = [301, 302, 303, 307, 308]

@theelous3
Copy link
Owner

theelous3 commented Aug 18, 2019

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

@njsmith
Copy link
Contributor Author

njsmith commented Aug 18, 2019

I hear ya...

@s0undt3ch
Copy link

I've just been bitten by this. No progress yet?

@theelous3
Copy link
Owner

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.

@CoolCat467
Copy link

Updates?

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

No branches or pull requests

4 participants