123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135(*{{{ Copyright (C) 2012-2014 Anil Madhavapeddy <anil@recoil.org>
* Copyright (c) 2014 Rudi Grinberg
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
}}}*)(** Module type signatures for Cohttp components *)(** The [IO] module defines the blocking interface for reading
and writing to Cohttp streams *)moduletypeIO=sig(** ['a t] represents a blocking monad state *)type+'at(** [a >>= b] will pass the result of [a] to the
[b] function. This is a monadic [bind]. *)val(>>=):'at->('a->'bt)->'bt(** [return a] will construct a constant IO value. *)valreturn:'a->'at(** [ic] represents an input channel *)typeic(** [oc] represents an output channel *)typeoc(** [conn] represents the underlying network flow *)typeconn(** [read_line ic] will read a single line terminated
by CR or CRLF from the input channel [ic]. It returns
{!None} if EOF or other error condition is reached. *)valread_line:ic->stringoptiont(** [read ic len] will block until a maximum of [len] characters
are read from the input channel [ic]. It returns an
empty string if EOF or some other error condition occurs
on the input channel, and can also return fewer than [len]
characters if input buffering is not sufficient to satisfy the
request. *)valread:ic->int->stringt(** [write oc s] will block until the complete [s] string is
written to the output channel [oc]. *)valwrite:oc->string->unitt(** [flush oc] will return when all previously buffered content
from calling {!write} have been written to the output channel
[oc]. *)valflush:oc->unittendmoduletypeHttp_io=sigtypettypereadertypewritermoduleIO:IOvalread:IO.ic->[`Eof|`Invalidofstring|`Okoft]IO.tvalhas_body:t->[`No|`Unknown|`Yes]valmake_body_writer:?flush:bool->t->IO.oc->writervalmake_body_reader:t->IO.ic->readervalread_body_chunk:reader->Transfer.chunkIO.tvalwrite_header:t->IO.oc->unitIO.tvalwrite_body:writer->string->unitIO.tvalwrite:?flush:bool->(writer->unitIO.t)->t->IO.oc->unitIO.tendmoduletypeRequest=sigtypet={headers:Header.t;(** HTTP request headers *)meth:Code.meth;(** HTTP request method *)resource:string;(** Request path and query *)version:Code.version;(** HTTP version, usually 1.1 *)encoding:Transfer.encoding;(** transfer encoding of this HTTP request *)}[@@derivingfields,sexp]valmake:?meth:Code.meth->?version:Code.version->?encoding:Transfer.encoding->?headers:Header.t->Uri.t->t(** Return true whether the connection should be reused *)valis_keep_alive:t->boolvaluri:t->Uri.tvalmake_for_client:?headers:Header.t->?chunked:bool->?body_length:int64->Code.meth->Uri.t->tendmoduletypeResponse=sigtypet={encoding:Transfer.encoding;(** Transfer encoding of this HTTP response *)headers:Header.t;(** response HTTP headers *)version:Code.version;(** (** HTTP version, usually 1.1 *) *)status:Code.status_code;(** HTTP status code of the response *)flush:bool;}[@@derivingfields,sexp]valmake:?version:Code.version->?status:Code.status_code->?flush:bool->?encoding:Transfer.encoding->?headers:Header.t->unit->tendmoduletypeBody=sigtypetvalto_string:t->stringvalto_string_list:t->stringlistvalempty:tvalis_empty:t->boolvalof_string:string->tvalof_string_list:stringlist->tvalmap:(string->string)->t->tvaltransfer_encoding:t->Transfer.encodingend