-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Handle unknown 1XX status codes better in client mode #1353
Comments
Yes, it's a bug. Thanks for report. |
I certainly can, though I'm not sure how quickly I can get to it. |
i do not think it is a bug. just limitations of current implementation. simplest solution is to accept coroutine as |
@fafhrd91 It would not be a bug if aiohttp simply ignored the 1XX: that would be fine. Treating it as a final response, however, is a bug. |
fixed in master |
Long story short
aiohttp's HTTP client does not tolerate non-100 or 101 status codes from the 1XX block in a sensible manner: it treats them as final responses, rather than as provisional ones.
Expected behaviour
When aiohttp receives a 1XX status code that it does not recognise, it should either surface these to a user that expects them by means of a callback, or it should ignore them and only show the user the eventual final status code. This is required by RFC 7231 Section 6.2 (Informational 1xx), which reads:
Actual behaviour
aiohttp treats the 1XX status code as final. It parses the header block as though it were a response in the 2XX or higher range. In most cases these 1XX response codes will not contain a content length or transfer-encoding directive, which means that aiohttp will fall back to reading until connection close. This will cause any following final response to be interpreted as part of the body of the 1XX response, rather than as its own unique response.
Steps to reproduce
The following "server" can demonstrate the issue:
If this server is run directly, the following client can be used to test it:
This client will print
This response is clearly wrong: the 200 header block is being treated as part of the 1XX response, rather than as a unique entity. Note that if
Content-Length: 0
is added to the 1XX response, this will still parse incorrectly, but now it will be treated as having zero length, and so will ruin the framing of the HTTP request/responses.Your environment
aiohttp version 1.0.5
Python 3.5.2
macOS 10.12.1
The text was updated successfully, but these errors were encountered: