Module Webs_http11.Request

Request codec.

val decode_line : bytes -> first:int -> last:int -> Webs.Http.Method.t * string * Webs.Http.Version.t

decode_line b ~first ~last decodes a request line that starts at first and whose ending CRLF starts at last+1. Raises Failure on errors.

TODO Do not expose this.

Decoding

val read : ?head_buffer:bytes -> ?log:string -> service_path:Webs.Http.Path.t -> Bytesrw.Bytes.Reader.t -> (Webs.Http.Request.t, Webs.Http.Response.t) Stdlib.result

read r reads an HTTP/1.1 request from r. The body of the request is an Http.Body.Bytes_reader on r.

The result is devised with Http.for_service_connector with the given service_path and thus satisfies the service requests conventions.

The function errors if the message header cannot fit in header_buffer or if a decoding error occurs.

Encoding

val encode_head : Webs.Http.Request.t -> string

encode_head request is the HTTP/1.1 message head of request: the request line, the crlf-terminated headers and the final crlf. The written headers go through Http.Headers.for_connector with the body request.

val encode : Webs.Http.Request.t -> string

encode request encodes request to an HTTP/1.1 request with encode_head followed by the request body.

Raises Invalid_argument on Webs.Http.Body.content.Custom bodies.

val write_head : Bytesrw.Bytes.Writer.t -> Webs.Http.Request.t -> unit

write_head w request writes encode_head of request on w.

val write : eod:bool -> Bytesrw.Bytes.Writer.t -> Webs.Http.Request.t -> unit

write ~eod w request writes request as an HTTP/1.1 request on w with write_head, followed by the request body, and a final Bytes.Slice.eod iff eod is true.

Raises Invalid_argument on Webs.Http.Body.content.Custom bodies.