Treatment connection
http/server::connection
Configuration
⬡ http_server: http/server::HttpServer
Parameters
↳ const method: HttpMethod (http/method::HttpMethod)
↳ const route: string
Required contexts
⥱ @HttpRequest: http/server::@HttpRequest
Inputs
⇥ data: Stream<byte>
⇥ headers: Block<StringMap> (std/data/string_map::StringMap)
⇥ status: Block<HttpStatus> (http/status::HttpStatus)
Outputs
↦ data: Stream<byte>
↦ error: Block<string>
↦ failed: Block<void>
↦ headers: Block<StringMap> (std/data/string_map::StringMap)
↦ started: Block<void>
Connection on HTTP server.
For every valid incoming HTTP request to http_server, a new track with all the outputs is created.
In order to start sending response to the requester, status and headers inputs must be filled.
status can be any valid HTTP code, for more informations please see the MDN Documentation.
⚠️ Drive status/headers/data (the response) from started, not from a trigger derived
from the incoming data (the request body). A request with no body (GET, HEAD, an empty
POST, …) never sends anything on data, so anything waiting for a first body value never
fires and the response is never sent. started is emitted as soon as the connection is
accepted, independently of whether the request has a body at all.
Outputs:
- started: emitted as soon as the connection is accepted, before any request body is read.
- headers: headers send in request.
- data: the raw body data received in the request.
- failed: emitted if a failure occurs during the processing of request.
- error: error message emitted if a failure occurs during the processing of request.
Inputs:
- status: HTTP status response.
- headers: headers to send in response.
- data: data to send in response, corresponding to the HTTP body.