-
Notifications
You must be signed in to change notification settings - Fork 91
Closed
Description
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:
def __init__(self, ...):
self.request_parser = httptools.HttpRequestParser(self)
...
# The asyncio.Protocol hooks...
...
def data_received(self, data):
print('data_received()')
try:
self.request_parser.feed_data(data)
except httptools.HttpParserUpgrade:
print('upgrade exception')
# Event hooks called back into by HttpRequestParser...
...
def on_headers_complete(self):
print('on_headers_complete()')
def on_message_complete(self):
print('on_message_complete()')
Output:
data_received()
on_headers_complete()
on_message_complete()
upgrade exception
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)
Metadata
Metadata
Assignees
Labels
No labels