Sanic: what tigger HTTPProtocol on_message_complete?

Created on 27 Mar 2018  路  2Comments  路  Source: sanic-org/sanic

what tigger HTTPProtocol on_message_complete?

Most helpful comment

@GzRichChen "on_message_complete" is a callback from HttpRequestParser (httptools library). It's triggered after the HTTP parser consumes all the HTTP request body (Sanic will feed the HTTP parser as data is received from asyncio). @ashleysommer your answer is wrong.

All 2 comments

Do you mean this?
https://github.com/channelcat/sanic/blob/79df52e519588112e43dd771dcd42ea245e732d2/sanic/server.py#L283

The HTTPProtocol is a subclass/extension of the asyncio.Protocol class. It is passed to the asyncio TCP socket data handler to act as the receiving protocol implementation.

It is the asyncio TCP service (in the case of Sanic, it is the one provided by uvloop) that calls on_message_complete after all packets of the TCP message has been received by the socket.

@GzRichChen "on_message_complete" is a callback from HttpRequestParser (httptools library). It's triggered after the HTTP parser consumes all the HTTP request body (Sanic will feed the HTTP parser as data is received from asyncio). @ashleysommer your answer is wrong.

Was this page helpful?
0 / 5 - 0 ratings