Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Shuttle_http.ServerSourcet represents a server connection handle. The lifecycle for the handle is the same as the underlying TCP connection.
type error_handler =
?exn:exn ->
?request:Request.t ->
Status.t ->
Response.t Async.Deferred.terror_handler can be used to customize how the server deals with any unhandled exceptions. A default implementation is provided that will respond with a status code and an empty response body.
A user provided service that is invoked for every request/response cycle for a HTTP connection.
val create :
?error_handler:error_handler ->
?read_header_timeout:Core.Time_ns.Span.t ->
Shuttle.Input_channel.t ->
Shuttle.Output_channel.t ->
tcreate ?error_handler ?read_header_timeout reader writer creates a new server handle that can be used to drive the HTTP request/response server loop.
error_handler is an optional input that allows customizing how unhandled exceptions, and any potential parsing or i/o errors get rendered. The default implementation will attempt to send an HTTP response with a status code and an empty body.read_header_timeout is the maximum time span that the server loop is allowed to read a request's headers. The default value is 60 seconds. If read_header_timeout is zero then no timeout is used, and the server could potentially wait forever attempting to read enough data to parse request headers.closed t returns a deferred that is resolved when the server connection handle is closed.
run t service accepts a server handle and a user provided service that will be invoked for each run of the request/response loop.
val respond_string :
t ->
?reason_phrase:string ->
?headers:Headers.t ->
?status:Status.t ->
string ->
Response.tresponse_string creates a new HTTP response from a string.
val respond_empty :
t ->
?reason_phrase:string ->
?headers:Headers.t ->
Status.t ->
Response.trespond_empty creates a new HTTP response with an empty body.
val respond_stream :
t ->
?reason_phrase:string ->
?headers:Headers.t ->
?status:Status.t ->
Body.Stream.t ->
Response.trespond_stream creates a new HTTP response from a user provided stream. If the stream remains unconsumed when a server handle is closed, the stream's close function is called so any resources help by the stream can be released.