Module Httpaf.Server_connection
type ttype error= Reqd.errortype request_handler= Reqd.t -> unittype error_handler= ?request:Request.t -> error -> (Headers.t -> [ `write ] Body.t) -> unit
val create : ?config:Config.t -> ?error_handler:error_handler -> request_handler -> tcreate ?config ?error_handler ~request_handlercreates a connection handler that will service individual requests withrequest_handler.
val next_read_operation : t -> [ `Read | `Yield | `Close ]next_read_operation treturns a value describing the next operation that the caller should conduct on behalf of the connection.
val read : t -> Bigstringaf.t -> off:int -> len:int -> intread t bigstring ~off ~lenreads bytes of input from the provided range ofbigstringand returns the number of bytes consumed by the connection.readshould be called afternext_read_operationreturns a`Readvalue and additional input is available for the connection to consume.
val read_eof : t -> Bigstringaf.t -> off:int -> len:int -> intread_eof t bigstring ~off ~lenreads bytes of input from the provided range ofbigstringand returns the number of bytes consumed by the connection.read_eofshould be called afternext_read_operationreturns a`Readand 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.
val yield_reader : t -> (unit -> unit) -> unityield_reader t continueregisters with the connection to callcontinuewhen reading should resume.yield_readershould be called afternext_read_operationreturns a`Yieldvalue.
val next_write_operation : t -> [ `Write of Bigstringaf.t IOVec.t list | `Yield | `Close of int ]next_write_operation treturns 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 ] -> unitreport_write_result t resultreports the result of the latest write attempt to the connection.report_write_resultshould be called after a call tonext_write_operationthat returns a`Write buffervalue.`Ok nindicates that the caller successfully wrotenbytes of output from the buffer that the caller was provided bynext_write_operation.`Closedindicates that the output destination will no longer accept bytes from the write processor.
val yield_writer : t -> (unit -> unit) -> unityield_writer t continueregisters with the connection to callcontinuewhen writing should resume.yield_writershould be called afternext_write_operationreturns a`Yieldvalue.
val report_exn : t -> exn -> unitreport_exn t exnreports that an errorexnhas been caught and that it has been attributed tot. Calling this function will switchtinto an error state. Depending on the statetis transitioning from, it may call its error handler before terminating the connection.
val is_closed : t -> boolis_closed tistrueif both the read and write processors have been shutdown. When this is the casenext_read_operationwill return`Close _andnext_write_operationwill return`Write _until all buffered output has been flushed.