HTTP
Configuring binary responses
Binary responses are determined using the Content-Type
and Content-Encoding
headers from the event request and a list of text MIME types.
Compression
If the Content-Encoding
header is set to gzip
or br
, then a binary response will be returned regardless of MIME type.
State machine
The HTTPCycle
is used by the adapter to communicate message events between the application and GCP. It is a state machine that handles the entire ASGI request and response cycle.
HTTPCycle
vellox.protocols.http.HTTPCycle
(scope, body)run
(self, app)receive
(self)send
(self, message)HTTPCycleState
vellox.protocols.http.HTTPCycleState
(value, names=None, *, module=None, qualname=None, type=None, start=1)The state of the ASGI http
connection.
* REQUEST - Initial state. The ASGI application instance will be run with the
connection scope containing the http
type.
* RESPONSE - The http.response.start
event has been sent by the application.
The next expected message is the http.response.body
event, containing the body
content. An application may pass the more_body
argument to send content in chunks,
however content will always be returned in a single response, never streamed.
* COMPLETE - The body content from the ASGI application has been completely
read. A disconnect event will be sent to the application, and the response will
be returned.