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

Incorrect response headers give a generic message instead of indicating a problem parsing the headers #674

Open
fhoeben opened this issue Jun 22, 2021 · 5 comments

Comments

@fhoeben
Copy link

fhoeben commented Jun 22, 2021

We are sending a request to a server that is sending incomplete response headers (i.e. last line of headers does not contain a :).

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Authorization, Content-Type, Accept, X-User-Email, X-Auth-Token
Allow: GET, POST, OPTIONS
Content-Type: text/html;charset=utf-8
Content-Length: 0
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Connection: keep-alive
ver


As a result we get a ConnectionError telling us 'error reading from socket: Could not parse data' (from Connection.read_more()). It would have been very helpful if we would get a message stating that the response headers were incorrect (and Connection.read_headers! which calls read_more does seem to indicate that in some cases).

@tarcieri
Copy link
Member

tarcieri commented Jun 22, 2021

For clarity, you're saying in this case that the \r\n\r\n delimiter between the headers and body is there, it's just there's one malformed header at the end? (ver)

If so, I would agree a better error message would indicate that the headers are malformed.

@fhoeben
Copy link
Author

fhoeben commented Jun 22, 2021

Yes. (and the actual body is empty)

@fhoeben
Copy link
Author

fhoeben commented Jun 22, 2021

I forgot to mention we are on version 4.4.1

@tarcieri
Copy link
Member

Aah, we completely changed parsers in v5.0, so I'd be curious if this problem persists

@fhoeben
Copy link
Author

fhoeben commented Jun 22, 2021

I just tried that, but my complaints about their broken headers are being taken seriously. They are trying to fix but currently the server is not responding at all...

I'll let you know if I can get a result with 5.0.0

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

2 participants