HTTPServer¶
HTTP protocol handler that manages parsing, response queuing, and connection lifecycle for a single HTTP connection.
Stored as a field inside an HTTPServerActor. Handles all HTTP-level
concerns — parsing incoming data, URI validation, response queue
management, idle timeout scheduling, and backpressure — and delivers
HTTP events to the actor via HTTPServerLifecycleEventReceiver
callbacks.
The protocol class implements lori's ServerLifecycleEventReceiver
to receive TCP-level events from the connection, processes them through
the HTTP parser, and forwards HTTP-level events to the owning actor.
Use none() as the field default so that this is ref in the
actor constructor body, then replace with create() or ssl():
actor MyServer is HTTPServerActor
var _http: HTTPServer = HTTPServer.none()
new create(auth: lori.TCPServerAuth, fd: U32,
config: ServerConfig)
=>
_http = HTTPServer(auth, fd, this, config)
class ref HTTPServer is
ServerLifecycleEventReceiver ref,
_RequestParserNotify ref,
_ResponseQueueNotify ref
Implements¶
- ServerLifecycleEventReceiver ref
- _RequestParserNotify ref
- _ResponseQueueNotify ref
Constructors¶
none¶
Create a placeholder protocol instance.
Used as the default value for the _http field in HTTPServerActor
implementations, allowing this to be ref in the actor constructor
body. The placeholder is immediately replaced by create() or ssl()
— its methods must never be called.
Returns¶
- HTTPServer ref^
create¶
Create the protocol handler for a plain HTTP connection.
Called inside the HTTPServerActor constructor. The server_actor
parameter must be the actor's this — it provides the
HTTPServerLifecycleEventReceiver ref for synchronous HTTP callbacks.
new ref create(
auth: TCPServerAuth val,
fd: U32 val,
server_actor: HTTPServerActor ref,
config: ServerConfig val)
: HTTPServer ref^
Parameters¶
- auth: TCPServerAuth val
- fd: U32 val
- server_actor: HTTPServerActor ref
- config: ServerConfig val
Returns¶
- HTTPServer ref^
ssl¶
Create the protocol handler for an HTTPS connection.
Like create, but wraps the TCP connection in SSL using the provided
SSLContext. Called inside the HTTPServerActor constructor for
HTTPS connections.
new ref ssl(
auth: TCPServerAuth val,
ssl_ctx: SSLContext val,
fd: U32 val,
server_actor: HTTPServerActor ref,
config: ServerConfig val)
: HTTPServer ref^
Parameters¶
- auth: TCPServerAuth val
- ssl_ctx: SSLContext val
- fd: U32 val
- server_actor: HTTPServerActor ref
- config: ServerConfig val
Returns¶
- HTTPServer ref^
Public Functions¶
request_received¶
fun ref request_received(
method: Method val,
raw_uri: String val,
version: ((HTTP10 val | HTTP11 val) & _Version val),
headers: Headers val)
: None val
Parameters¶
- method: Method val
- raw_uri: String val
- version: ((HTTP10 val | HTTP11 val) & _Version val)
- headers: Headers val
Returns¶
- None val
body_chunk¶
Parameters¶
Returns¶
- None val
request_complete¶
Returns¶
- None val
parse_error¶
fun ref parse_error(
err: ((TooLarge val | UnknownMethod val | InvalidURI val |
InvalidVersion val | MalformedHeaders val | InvalidContentLength val |
InvalidChunk val | BodyTooLarge val) & _ParseError val))
: None val
Parameters¶
- err: ((TooLarge val | UnknownMethod val | InvalidURI val | InvalidVersion val | MalformedHeaders val | InvalidContentLength val | InvalidChunk val | BodyTooLarge val) & _ParseError val)
Returns¶
- None val
close¶
Close the connection from the server actor.
Use this when the actor needs to force-close the connection — for
example, after rejecting a request early (413 Payload Too Large) via
the Responder delivered in on_request(). Safe to call at any time;
idempotent due to the _Active state guard.
Returns¶
- None val