http
http copied to clipboard
Incorrect response headers give a generic message instead of indicating a problem parsing the headers
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).
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.
Yes. (and the actual body is empty)
I forgot to mention we are on version 4.4.1
Aah, we completely changed parsers in v5.0, so I'd be curious if this problem persists
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