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
HttpParserUpgrade raised after event hooks are called. #17
Comments
My current approach is:
That works fine, only downside being a small amount of extra work in Python-land that could perhaps be dealt with by the parser, if the exception was raised prior to the event hooks being called. I guess good options would be:
|
Okay, looks like this is a limitation of the underlying library...
I'll close the issue off. |
hi. also got HttpParserUpgrade when parsing
if replace the b'\r\n\r\n' with b\r\n' the error is disappears made more tests. parsing the request above and even replacing '\r\n\r\n' not works correctly: callback functions such as on_message_complete, on_headers_complete not fired at all. |
cf #29 for the record |
@ramonz I think it's expected behaviour, see https://github.com/nodejs/http-parser/blob/0264a0aefcd119e179a3bc730ac517efbbccd4bb/http_parser.c#L1319 |
The
HttpParserUpgrade
exception appears to get called after the event hooks have been called into (at least with small requests that fit into a single data_received call)This makes it not terribly useful, as we may have already called into a handler function / issued a response / etc... by the time the upgrade is raised.
Sketch of protocol class:
Output:
On first sight this looks awkward to resolve, so it could just be considered a constraint of the implementation, and deal with it in python-land instead (which would be acceptable from my POV)
The text was updated successfully, but these errors were encountered: