type request_handler = Reqd.t -> unit
create ?config ?error_handler ~request_handler creates a connection handler that will service individual requests with
val next_read_operation : t -> [ `Read | `Close ]
next_read_operation t returns a value describing the next operation that the caller should conduct on behalf of the connection.
read t bigstring ~off ~len reads bytes of input from the provided range of
bigstring and returns the number of bytes consumed by the connection.
read should be called after
next_read_operation returns a
`Read and an EOF has been received from the communication channel. The connection will attempt to consume any buffered input and then shutdown the HTTP parser for the connection.
next_write_operation t returns a value describing the next operation that the caller should conduct on behalf of the connection.
val report_write_result : t -> [ `Ok of int | `Closed ] -> unit
report_write_result t result reports the result of the latest write attempt to the connection.
report_write_result should be called after a call to
next_write_operation that returns a
`Write buffer value.
`Ok nindicates that the caller successfully wrote
nbytes of output from the buffer that the caller was provided by
`Closedindicates that the output destination will no longer accept bytes from the write processor.
val yield_writer : t -> ( unit -> unit ) -> unit
val report_exn : t -> exn -> unit
report_exn t exn reports that an error
exn has been caught and that it has been attributed to
t. Calling this function will switch
t into an error state. Depending on the state
t is transitioning from, it may call its error handler before terminating the connection.
val is_closed : t -> bool
error_code t returns the
error_code that caused the connection to close, if one exists.