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
IndexError when handle malformed http response #1286
Comments
I'll see if I can replicate soon and figure out the right strategy. In the original, are those header fields spaced out with |
the source response is
|
Okay, so we're correctly dropping those "headers" because they're not actually headers (tab character is disallowed in header field names). This results in a response that has no headers, but we have a piece of logic that expects at least one. I'll need to dig in and see if there are any other places that would be unhappy with a headerless response and if so, what kind of effort would be involved with cleaning that up. @sigmavirus24, thoughts? I don't think we want to try to figure out what the server means when it sends an invalid header; it's too ambiguous. |
@haikuginger we're not correctly dropping them necessarily. We're expecting valid headers. The server is wrong and I think we should raise an InvalidHeader exception of sorts in this case, especially when we can't just try to add it onto the previous header. |
In this instance I think the error is coming from httplib, so we may not be able to raise that error easily. |
Okay, I'm just getting back to this. This is our code, not httplib, and what's happening is that we're interpreting a line that starts with I propose that we adjust the implementation such that...
@sigmavirus24, does that seem reasonable to you? Note to @beruhan: this will not prevent an exception from happening for the response you've listed above, but will make that exception more explicit and helpful, so that you can catch it and take action accordingly. |
@haikuginger yeah, 2 is what we're missing and definitely seems reasonable. 👍 |
@beruhan, we've pushed a change to master that will result in a more comprehensible error for a response that's malformed in this way. Thanks for putting this in front of us! |
I use urllib3 receive a http response like this,
it throws a IndexError,I print the traceback,
how can I deal with this issue?
The text was updated successfully, but these errors were encountered: