Webs_http11HTTP/1.1 (de)serialization
val decode_version : string -> (Webs.Http.Version.t, string) Stdlib.resultdecode_version s decodes a version in HTTP/1.1 syntax from s. Single digit versions are also parsed, some serializations (e.g. the curl tool) do that.
val encode_version : Webs.Http.Version.t -> stringhttp11_encode v encodes the version v in HTTP/1.1 syntax. Assumes correct integer ranges.
val decode_headers : bytes -> crlfs:int list -> Webs.Http.Headers.tdecode_headers b crlfs decodes the headers. b has the header section with the start line (either request or status line) or finished by the first crlfs.
val decode_request_line :
bytes ->
first:int ->
crlf:int ->
Webs.Http.Method.t * string * Webs.Http.Version.tdecode_request_line b ~first ~crlf decodes a request line that starts at first and whose ending CRLF starts at crlf. Raises Failure on errors.
val encode_request_head : Webs.Http.Request.t -> stringencode_request_head request is the message head of request: the start line, the crlf-terminated headers and the final crlf.
This calls Webs.Http.Headers.for_connector to determine the headers and the value of Webs.Http.Request.version is ignored.
val encode_request : Webs.Http.Request.t -> (string, string) Stdlib.resultencode_request ~include_body request encodes request to an HTTP/1.1 request with encode_request_head and appends the body.
This errors on Webs.Http.Body.content.Custom bodies.
val write_request_head : Bytesrw.Bytes.Writer.t -> Webs.Http.Request.t -> unitwrite_request_head w request writes the result of encode_request_head on w.
val write_request :
eod:bool ->
Bytesrw.Bytes.Writer.t ->
Webs.Http.Request.t ->
(unit, string) Stdlib.resultwrite_request ~eod w writes the result of encode_request on w (but streams the bodies if possible).
val decode_status_line :
bytes ->
first:int ->
crlf:int ->
Webs.Http.Version.t * Webs.Http.Status.t * stringdecode_status_line b ~first ~crlf decodes a status line that starts at first and whose ending CRLF starts at crlf. Raises Failure on errors.
val decode_response : bytes -> first:int -> Webs.Http.Response.tdecode_response b ~first body decodes an HTTP/1.1 full response from b starting at first. The result satisfies client responses. Raises Failure on errors.
val read_response :
?head_buffer:bytes ->
Bytesrw.Bytes.Reader.t ->
(Webs.Http.Response.t, string) Stdlib.resultread_response r reads a response using head_buffer to store the response head, defaults to a fresh buffer of size Http.Connector.Default.max_request_headers_byte_size.
val encode_response_head :
Webs.Http.Status.t ->
reason:string ->
Webs.Http.Headers.t ->
stringencode_http11_response_head is the HTTP/1.1 head for a response with the given parameters. This has the final double CRLF.
val encode_response :
include_body:bool ->
Webs.Http.Response.t ->
(string, string) Stdlib.resultencode_http11 ~include_body response encodes response to an HTTP/1.1 response. If include_body is true the body is consumed and included in the result. If false the body is left untouched and the encoding stops after the header final double CRLF.