Page
Library
Module
Module type
Parameter
Class
Class type
Source
Cohttp_eio.ServerSourceServer is a HTTP 1.1 server.
The request headers, a reader for the socket, and the address of the client. To read the request body, use read_fixed or read_chunked.
type 'a env =
< domain_mgr : Eio.Domain_manager.t
; net : Eio.Net.t
; clock : Eio.Time.clock.. > as 'aread_fixed (request, buf_read) is Some content, where content is of length n if "Content-Length" header is a valid integer value n in request.
buf_read is updated to reflect that n bytes was read.
If "Content-Length" header is missing or is an invalid value in request OR if the request http method is not one of POST, PUT or PATCH, then None is returned.
val read_chunked :
Http.Request.t ->
Eio.Buf_read.t ->
(Body.chunk -> unit) ->
Http.Header.t optionread_chunked request buf_read chunk_handler is Some updated_headers if "Transfer-Encoding" header value is "chunked" in request and all chunks in buf_read are read successfully. updated_headers is the updated headers as specified by the chunked encoding algorithm in https: //datatracker.ietf.org/doc/html/rfc7230#section-4.1.3.
buf_read is updated to reflect the number of bytes read. Returns None if Transfer-Encoding header in headers is not specified as "chunked"
text t s returns a HTTP/1.1, 200 status response with "Content-Type" header set to "text/plain".
html t s returns a HTTP/1.1, 200 status response with header set to "Content-Type: text/html".
internal_server_error returns a HTTP/1.1, 500 status response.
run ~socket_backlog ~domains ~port env handler runs a HTTP/1.1 server executing handler and listening on port. env corresponds to Eio.Stdenv.t.
socket_backlog is the number of pending connections for tcp server socket. The default is 128.
domains is the number of OCaml 5.0 domains the server will use. The default is 1. You may use Domain.recommended_domain_count to configure a multicore capable server.
val connection_handler :
handler ->
Eio.Time.clock ->
Eio.Flow.two_way ->
Eio.Net.Sockaddr.stream ->
unitconnection_handler request_handler is a connection handler, suitable for passing to Eio.Net.accept_fork.