Module Webs_unix.Fd

File descriptor tools.

type Webs.Http.Body.custom_content +=
  1. | Writer of Unix.file_descr Webs.Http.Body.writer
    (*

    The type for direct file descriptor body writers.

    These writers write their bodies directly on the output file descriptor given to them.

    *)

Uninterrupted reads and writes

val read : Unix.file_descr -> bytes -> start:int -> length:int -> int

read fd b ~start ~len reads at most len bytes of fd into b starting at start. Raises Unix.Unix_error but handles Unix.EINTR.

val write : Unix.file_descr -> bytes -> start:int -> length:int -> unit

write fd b ~start ~len writes len byte of b starting at start on fd. Raises Unix.Unix_error but handles Unix.EINTR.

Body reader and writers

val bytes_reader : max_request_body_byte_size:int -> content_length:int option -> Unix.file_descr -> bytes -> first_start:int -> first_len:int -> Bytesrw.Bytes.Reader.t

bytes_reader fd b ~start ~start_len is a bytes reader for fd using buffer b and assuming the first first_len bytes are already in b at first_start.

val body_writer : Webs.Http.Body.t -> Unix.file_descr Webs.Http.Body.writer

body_writer b is a body writer for b writing on a given file descriptors. This supports bodies with the following content:

HTTP/1.1 support

val read_http11_head_crlfs : max_bytes:int -> bytes -> Unix.file_descr -> int list * int * int

read_http11_crlfs reads the status line and headers in bytes up-to max_bytes. Returns the list of crlf locations, the start of the body and how much was read from the body. Raises Failure and Unix.Unix_error

val write_http11_request : Unix.file_descr -> Webs.Http.Request.t -> unit

write_http_request fd request writes request as an an HTTP/1.1 request on fd. This calls Webs.Http.Headers.for_connector on the headers and the value of Webs.Http.Request.version is ignored.