handy_http_transport.http1.transport

Undocumented in source.

Members

Aliases

HttpRequestParseResult
alias HttpRequestParseResult = Either!(ServerHttpRequest, "request", StreamError, "error")

Alias for the result of the readHttpRequest function which parses HTTP requests.

Classes

Http1Transport
class Http1Transport

Base class for HTTP/1.1 transport, where different subclasses can define how the actual socket communication works (threadpool / epoll/ etc).

Functions

getAddress
ClientAddress getAddress(Socket socket)

Gets a ClientAddress value from a socket's address information.

handleClient
void handleClient(Socket clientSocket, HttpRequestHandler requestHandler)

The main logic for handling an incoming request from a client. It involves reading bytes from the client, parsing them as an HTTP request, passing that to the HTTP Transport's request handler, and then writing the response back to the client.

parseHeaders
Either!(string[][string], "headers", StreamError, "error") parseHeaders(S inputStream)

Parses HTTP headers from an input stream, and returns them as an associative array mapping header names to their list of values.

readHttpRequest
HttpRequestParseResult readHttpRequest(S inputStream, ClientAddress addr)

Parses an HTTP/1.1 request from a byte input stream.

testHttp1Transport
void testHttp1Transport(Http1Transport transport)

A generic test to ensure that any Http1Transport implementation behaves properly to start & stop, and process requests when running.