From 2f2a106f0c7916dd5d702d799d2d4c410b8866f7 Mon Sep 17 00:00:00 2001 From: c-cube Date: Tue, 8 Aug 2023 18:35:40 +0000 Subject: [PATCH] deploy: b36ea35703ac4c634ef27f6d92424737f80d1642 --- .../Tiny_httpd_dir/Embedded_fs/index.html | 2 -- .../Tiny_httpd_dir/module-type-VFS/index.html | 2 -- dev/tiny_httpd/Tiny_httpd_html_/A/index.html | 2 -- .../Tiny_httpd_html_/Out/index.html | 2 -- dev/tiny_httpd/Tiny_httpd_io/Input/index.html | 2 -- .../Tiny_httpd_io/Output/index.html | 2 -- .../Tiny_httpd_io/TCP_server/index.html | 2 -- .../Tiny_httpd_io/Writer/index.html | 2 -- .../Tiny_httpd_server/Headers/index.html | 2 -- .../Tiny_httpd_server/Meth/index.html | 2 -- .../Tiny_httpd_server/Middleware/index.html | 2 -- .../Tiny_httpd_server/Request/index.html | 6 ----- .../Tiny_httpd_server/Response/index.html | 26 ------------------- .../Response_code/index.html | 2 -- .../Tiny_httpd_server/Route/index.html | 2 -- .../module-type-IO_BACKEND/index.html | 2 -- .../index.html | 8 ------ 17 files changed, 68 deletions(-) delete mode 100644 dev/tiny_httpd/Tiny_httpd_dir/Embedded_fs/index.html delete mode 100644 dev/tiny_httpd/Tiny_httpd_dir/module-type-VFS/index.html delete mode 100644 dev/tiny_httpd/Tiny_httpd_html_/A/index.html delete mode 100644 dev/tiny_httpd/Tiny_httpd_html_/Out/index.html delete mode 100644 dev/tiny_httpd/Tiny_httpd_io/Input/index.html delete mode 100644 dev/tiny_httpd/Tiny_httpd_io/Output/index.html delete mode 100644 dev/tiny_httpd/Tiny_httpd_io/TCP_server/index.html delete mode 100644 dev/tiny_httpd/Tiny_httpd_io/Writer/index.html delete mode 100644 dev/tiny_httpd/Tiny_httpd_server/Headers/index.html delete mode 100644 dev/tiny_httpd/Tiny_httpd_server/Meth/index.html delete mode 100644 dev/tiny_httpd/Tiny_httpd_server/Middleware/index.html delete mode 100644 dev/tiny_httpd/Tiny_httpd_server/Request/index.html delete mode 100644 dev/tiny_httpd/Tiny_httpd_server/Response/index.html delete mode 100644 dev/tiny_httpd/Tiny_httpd_server/Response_code/index.html delete mode 100644 dev/tiny_httpd/Tiny_httpd_server/Route/index.html delete mode 100644 dev/tiny_httpd/Tiny_httpd_server/module-type-IO_BACKEND/index.html delete mode 100644 dev/tiny_httpd/Tiny_httpd_server/module-type-SERVER_SENT_GENERATOR/index.html diff --git a/dev/tiny_httpd/Tiny_httpd_dir/Embedded_fs/index.html b/dev/tiny_httpd/Tiny_httpd_dir/Embedded_fs/index.html deleted file mode 100644 index f62ccfb8..00000000 --- a/dev/tiny_httpd/Tiny_httpd_dir/Embedded_fs/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Embedded_fs (tiny_httpd.Tiny_httpd_dir.Embedded_fs)

Module Tiny_httpd_dir.Embedded_fs

An embedded file system, as a list of files with (relative) paths. This is useful in combination with the "tiny-httpd-mkfs" tool, which embeds the files it's given into a OCaml module.

type t

The pseudo-filesystem

val create : ?mtime:float -> unit -> t
val add_file : ?mtime:float -> t -> path:string -> string -> unit

Add file to the virtual file system.

  • raises Invalid_argument

    if the path contains '..' or if it tries to make a directory out of an existing path that is a file.

val to_vfs : t -> (module VFS)
\ No newline at end of file diff --git a/dev/tiny_httpd/Tiny_httpd_dir/module-type-VFS/index.html b/dev/tiny_httpd/Tiny_httpd_dir/module-type-VFS/index.html deleted file mode 100644 index 0d0d410b..00000000 --- a/dev/tiny_httpd/Tiny_httpd_dir/module-type-VFS/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -VFS (tiny_httpd.Tiny_httpd_dir.VFS)

Module type Tiny_httpd_dir.VFS

Virtual file system.

This is used to emulate a file system from pure OCaml functions and data, e.g. for resources bundled inside the web server.

val descr : string

Description of the VFS

val is_directory : string -> bool
val contains : string -> bool

file_exists vfs path returns true if path points to a file or directory inside vfs.

val list_dir : string -> string array

List directory. This only returns basenames, the files need to be put in the directory path using Filename.concat.

val delete : string -> unit

Delete path

val create : string -> (bytes -> int -> int -> unit) * (unit -> unit)

Create a file and obtain a pair write, close

val read_file_content : string -> Tiny_httpd_stream.t

Read content of a file

val file_size : string -> int option

File size, e.g. using "stat"

val file_mtime : string -> float option

File modification time, e.g. using "stat"

\ No newline at end of file diff --git a/dev/tiny_httpd/Tiny_httpd_html_/A/index.html b/dev/tiny_httpd/Tiny_httpd_html_/A/index.html deleted file mode 100644 index 76232721..00000000 --- a/dev/tiny_httpd/Tiny_httpd_html_/A/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -A (tiny_httpd.Tiny_httpd_html_.A)

Module Tiny_httpd_html_.A

Attributes.

This module contains combinator for the standard attributes. One can also just use a pair of strings.

type t = string -> attribute

Attribute builder

val accept : t

Attribute "accept".

val accept_charset : t

Attribute "accept-charset".

val accesskey : t

Attribute "accesskey".

val action : t

Attribute "action".

val align : t

Attribute "align".

val allow : t

Attribute "allow".

val alt : t

Attribute "alt".

val async : t

Attribute "async".

val autocapitalize : t

Attribute "autocapitalize".

val autocomplete : t

Attribute "autocomplete".

val autofocus : t

Attribute "autofocus".

val autoplay : t

Attribute "autoplay".

val buffered : t

Attribute "buffered".

val capture : t

Attribute "capture".

val challenge : t

Attribute "challenge".

val charset : t

Attribute "charset".

val checked : t

Attribute "checked".

val cite : t

Attribute "cite".

val class_ : t

Attribute "class".

val code : t

Attribute "code".

val codebase : t

Attribute "codebase".

val cols : t

Attribute "cols".

val colspan : t

Attribute "colspan".

val content : t

Attribute "content".

val contenteditable : t

Attribute "contenteditable".

val contextmenu : t

Attribute "contextmenu".

val controls : t

Attribute "controls".

val coords : t

Attribute "coords".

val crossorigin : t

Attribute "crossorigin".

val csp : t

Attribute "csp".

val data : t

Attribute "data".

val data_star : t

Attribute "data-*".

val datetime : t

Attribute "datetime".

val decoding : t

Attribute "decoding".

val default : t

Attribute "default".

val defer : t

Attribute "defer".

val dir : t

Attribute "dir".

val dirname : t

Attribute "dirname".

val disabled : t

Attribute "disabled".

val download : t

Attribute "download".

val draggable : t

Attribute "draggable".

val enctype : t

Attribute "enctype".

val enterkeyhint : t

Attribute "enterkeyhint".

val for_ : t

Attribute "for".

val form : t

Attribute "form".

val formaction : t

Attribute "formaction".

val formenctype : t

Attribute "formenctype".

val formmethod : t

Attribute "formmethod".

val formnovalidate : t

Attribute "formnovalidate".

val formtarget : t

Attribute "formtarget".

val headers : t

Attribute "headers".

val hidden : t

Attribute "hidden".

val high : t

Attribute "high".

val href : t

Attribute "href".

val hreflang : t

Attribute "hreflang".

val http_equiv : t

Attribute "http-equiv".

val icon : t

Attribute "icon".

val id : t

Attribute "id".

val importance : t

Attribute "importance".

val integrity : t

Attribute "integrity".

val ismap : t

Attribute "ismap".

val itemprop : t

Attribute "itemprop".

val keytype : t

Attribute "keytype".

val kind : t

Attribute "kind".

val label : t

Attribute "label".

val lang : t

Attribute "lang".

val language : t

Attribute "language".

val list : t

Attribute "list".

val loop : t

Attribute "loop".

val low : t

Attribute "low".

val manifest : t

Attribute "manifest".

val max : t

Attribute "max".

val maxlength : t

Attribute "maxlength".

val minlength : t

Attribute "minlength".

val media : t

Attribute "media".

val method_ : t

Attribute "method".

val min : t

Attribute "min".

val multiple : t

Attribute "multiple".

val muted : t

Attribute "muted".

val name : t

Attribute "name".

val novalidate : t

Attribute "novalidate".

val open_ : t

Attribute "open".

val optimum : t

Attribute "optimum".

val pattern : t

Attribute "pattern".

val ping : t

Attribute "ping".

val placeholder : t

Attribute "placeholder".

val poster : t

Attribute "poster".

val preload : t

Attribute "preload".

val radiogroup : t

Attribute "radiogroup".

val readonly : t

Attribute "readonly".

val referrerpolicy : t

Attribute "referrerpolicy".

val rel : t

Attribute "rel".

val required : t

Attribute "required".

val reversed : t

Attribute "reversed".

val rows : t

Attribute "rows".

val rowspan : t

Attribute "rowspan".

val sandbox : t

Attribute "sandbox".

val scope : t

Attribute "scope".

val scoped : t

Attribute "scoped".

val selected : t

Attribute "selected".

val shape : t

Attribute "shape".

val size : t

Attribute "size".

val sizes : t

Attribute "sizes".

val slot : t

Attribute "slot".

val span : t

Attribute "span".

val spellcheck : t

Attribute "spellcheck".

val src : t

Attribute "src".

val srcdoc : t

Attribute "srcdoc".

val srclang : t

Attribute "srclang".

val srcset : t

Attribute "srcset".

val start : t

Attribute "start".

val step : t

Attribute "step".

val style : t

Attribute "style".

val summary : t

Attribute "summary".

val tabindex : t

Attribute "tabindex".

val target : t

Attribute "target".

val title : t

Attribute "title".

val translate : t

Attribute "translate".

val text : t

Attribute "Text".

val type_ : t

Attribute "type".

val usemap : t

Attribute "usemap".

val value : t

Attribute "value".

val width : t

Attribute "width".

val wrap : t

Attribute "wrap".

\ No newline at end of file diff --git a/dev/tiny_httpd/Tiny_httpd_html_/Out/index.html b/dev/tiny_httpd/Tiny_httpd_html_/Out/index.html deleted file mode 100644 index 42f847eb..00000000 --- a/dev/tiny_httpd/Tiny_httpd_html_/Out/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Out (tiny_httpd.Tiny_httpd_html_.Out)

Module Tiny_httpd_html_.Out

Output for HTML combinators.

This output type is used to produce a string reasonably efficiently from a tree of combinators.

NOTE: this is experimental and an unstable API.

type t
val create_of_buffer : Stdlib.Buffer.t -> t
val create_of_out : Tiny_httpd_io.Output.t -> t
val flush : t -> unit
val add_char : t -> char -> unit
val add_string : t -> string -> unit
val add_format_nl : t -> unit
val with_no_format_nl : t -> (unit -> 'a) -> 'a
\ No newline at end of file diff --git a/dev/tiny_httpd/Tiny_httpd_io/Input/index.html b/dev/tiny_httpd/Tiny_httpd_io/Input/index.html deleted file mode 100644 index de36c737..00000000 --- a/dev/tiny_httpd/Tiny_httpd_io/Input/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Input (tiny_httpd.Tiny_httpd_io.Input)

Module Tiny_httpd_io.Input

Input channel (byte source)

type t = {
  1. input : bytes -> int -> int -> int;
    (*

    Read into the slice. Returns 0 only if the channel is closed.

    *)
  2. close : unit -> unit;
    (*

    Close the input. Must be idempotent.

    *)
}

An input channel, i.e an incoming stream of bytes.

This can be a string, an int_channel, an Unix.file_descr, a decompression wrapper around another input channel, etc.

val of_in_channel : ?close_noerr:bool -> Stdlib.in_channel -> t
val of_unix_fd : ?close_noerr:bool -> Unix.file_descr -> t
val input : t -> bytes -> int -> int -> int

Read into the given slice.

  • returns

    the number of bytes read, 0 means end of input.

val close : t -> unit

Close the channel.

\ No newline at end of file diff --git a/dev/tiny_httpd/Tiny_httpd_io/Output/index.html b/dev/tiny_httpd/Tiny_httpd_io/Output/index.html deleted file mode 100644 index 6ddcf430..00000000 --- a/dev/tiny_httpd/Tiny_httpd_io/Output/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Output (tiny_httpd.Tiny_httpd_io.Output)

Module Tiny_httpd_io.Output

Output channel (byte sink)

type t = {
  1. output_char : char -> unit;
    (*

    Output a single char

    *)
  2. output : bytes -> int -> int -> unit;
    (*

    Output slice

    *)
  3. flush : unit -> unit;
    (*

    Flush underlying buffer

    *)
  4. close : unit -> unit;
    (*

    Close the output. Must be idempotent.

    *)
}

An output channel, ie. a place into which we can write bytes.

This can be a Buffer.t, an out_channel, a Unix.file_descr, etc.

val of_out_channel : ?close_noerr:bool -> Stdlib.out_channel -> t

of_out_channel oc wraps the channel into a Output.t.

  • parameter close_noerr

    if true, then closing the result uses close_out_noerr instead of close_out to close oc

val of_buffer : Stdlib.Buffer.t -> t

of_buffer buf is an output channel that writes directly into buf. flush and close have no effect.

val output_char : t -> char -> unit

Output the buffer slice into this channel

val output : t -> bytes -> int -> int -> unit

Output the buffer slice into this channel

val output_string : t -> string -> unit
val close : t -> unit

Close the channel.

val flush : t -> unit

Flush (ie. force write) any buffered bytes.

val output_buf : t -> Buf.t -> unit
val chunk_encoding : ?buf:Buf.t -> close_rec:bool -> t -> t

chunk_encoding oc makes a new channel that outputs its content into oc in chunk encoding form.

  • parameter close_rec

    if true, closing the result will also close oc

  • parameter buf

    a buffer used to accumulate data into chunks. Chunks are emitted when buf's size gets over a certain threshold, or when flush is called.

\ No newline at end of file diff --git a/dev/tiny_httpd/Tiny_httpd_io/TCP_server/index.html b/dev/tiny_httpd/Tiny_httpd_io/TCP_server/index.html deleted file mode 100644 index 7d9ee235..00000000 --- a/dev/tiny_httpd/Tiny_httpd_io/TCP_server/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -TCP_server (tiny_httpd.Tiny_httpd_io.TCP_server)

Module Tiny_httpd_io.TCP_server

A TCP server abstraction.

type conn_handler = {
  1. handle : Input.t -> Output.t -> unit;
    (*

    Handle client connection

    *)
}
type t = {
  1. endpoint : unit -> string * int;
    (*

    Endpoint we listen on. This can only be called from within serve.

    *)
  2. active_connections : unit -> int;
    (*

    Number of connections currently active

    *)
  3. running : unit -> bool;
    (*

    Is the server currently running?

    *)
  4. stop : unit -> unit;
    (*

    Ask the server to stop. This might not take effect immediately, and is idempotent. After this server.running() must return false.

    *)
}

A running TCP server.

This contains some functions that provide information about the running server, including whether it's active (as opposed to stopped), a function to stop it, and statistics about the number of connections.

type builder = {
  1. serve : after_init:(t -> unit) -> handle:conn_handler -> unit -> unit;
    (*

    Blocking call to listen for incoming connections and handle them. Uses the connection handler handle to handle individual client connections in individual threads/fibers/tasks.

    • parameter after_init

      is called once with the server after the server has started.

    *)
}

A TCP server builder implementation.

Calling builder.serve ~after_init ~handle () starts a new TCP server on an unspecified endpoint (most likely coming from the function returning this builder) and returns the running server.

\ No newline at end of file diff --git a/dev/tiny_httpd/Tiny_httpd_io/Writer/index.html b/dev/tiny_httpd/Tiny_httpd_io/Writer/index.html deleted file mode 100644 index d0e9b2da..00000000 --- a/dev/tiny_httpd/Tiny_httpd_io/Writer/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Writer (tiny_httpd.Tiny_httpd_io.Writer)

Module Tiny_httpd_io.Writer

A writer abstraction.

type t = {
  1. write : Output.t -> unit;
}

Writer.

A writer is a push-based stream of bytes. Give it an output channel and it will write the bytes in it.

This is useful for responses: an http endpoint can return a writer as its response's body, and output into it as if it were a regular out_channel, including controlling calls to flush.

  • since NEXT_RELEASE
val make : write:(Output.t -> unit) -> unit -> t
val write : Output.t -> t -> unit

Write into the channel.

val empty : t

Empty writer, will output 0 bytes.

val of_string : string -> t

A writer that just emits the bytes from the given string.

\ No newline at end of file diff --git a/dev/tiny_httpd/Tiny_httpd_server/Headers/index.html b/dev/tiny_httpd/Tiny_httpd_server/Headers/index.html deleted file mode 100644 index f418a291..00000000 --- a/dev/tiny_httpd/Tiny_httpd_server/Headers/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Headers (tiny_httpd.Tiny_httpd_server.Headers)

Module Tiny_httpd_server.Headers

type t = (string * string) list

The header files of a request or response.

Neither the key nor the value can contain '\r' or '\n'. See https://tools.ietf.org/html/rfc7230#section-3.2

val empty : t

Empty list of headers.

  • since 0.5
val get : ?f:(string -> string) -> string -> t -> string option

get k headers looks for the header field with key k.

  • parameter f

    if provided, will transform the value before it is returned.

val set : string -> string -> t -> t

set k v headers sets the key k to value v. It erases any previous entry for k

val remove : string -> t -> t

Remove the key from the headers, if present.

val contains : string -> t -> bool

Is there a header with the given key?

val pp : Stdlib.Format.formatter -> t -> unit

Pretty print the headers.

\ No newline at end of file diff --git a/dev/tiny_httpd/Tiny_httpd_server/Meth/index.html b/dev/tiny_httpd/Tiny_httpd_server/Meth/index.html deleted file mode 100644 index b0b3305b..00000000 --- a/dev/tiny_httpd/Tiny_httpd_server/Meth/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Meth (tiny_httpd.Tiny_httpd_server.Meth)

Module Tiny_httpd_server.Meth

type t = [
  1. | `GET
  2. | `PUT
  3. | `POST
  4. | `HEAD
  5. | `DELETE
  6. | `OPTIONS
]

A HTTP method. For now we only handle a subset of these.

See https://tools.ietf.org/html/rfc7231#section-4

val pp : Stdlib.Format.formatter -> t -> unit
val to_string : t -> string
\ No newline at end of file diff --git a/dev/tiny_httpd/Tiny_httpd_server/Middleware/index.html b/dev/tiny_httpd/Tiny_httpd_server/Middleware/index.html deleted file mode 100644 index 70876c01..00000000 --- a/dev/tiny_httpd/Tiny_httpd_server/Middleware/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Middleware (tiny_httpd.Tiny_httpd_server.Middleware)

Module Tiny_httpd_server.Middleware

type handler = byte_stream Request.t -> resp:(Response.t -> unit) -> unit

Handlers are functions returning a response to a request. The response can be delayed, hence the use of a continuation as the resp parameter.

type t = handler -> handler

A middleware is a handler transformation.

It takes the existing handler h, and returns a new one which, given a query, modify it or log it before passing it to h, or fail. It can also log or modify or drop the response.

val nil : t

Trivial middleware that does nothing.

\ No newline at end of file diff --git a/dev/tiny_httpd/Tiny_httpd_server/Request/index.html b/dev/tiny_httpd/Tiny_httpd_server/Request/index.html deleted file mode 100644 index 5af27b92..00000000 --- a/dev/tiny_httpd/Tiny_httpd_server/Request/index.html +++ /dev/null @@ -1,6 +0,0 @@ - -Request (tiny_httpd.Tiny_httpd_server.Request)

Module Tiny_httpd_server.Request

type 'body t = private {
  1. meth : Meth.t;
    (*

    HTTP method for this request.

    *)
  2. host : string;
    (*

    Host header, mandatory. It can also be found in headers.

    *)
  3. headers : Headers.t;
    (*

    List of headers.

    *)
  4. http_version : int * int;
    (*

    HTTP version. This should be either 1, 0 or 1, 1.

    *)
  5. path : string;
    (*

    Full path of the requested URL.

    *)
  6. path_components : string list;
    (*

    Components of the path of the requested URL.

    *)
  7. query : (string * string) list;
    (*

    Query part of the requested URL.

    *)
  8. body : 'body;
    (*

    Body of the request.

    *)
  9. start_time : float;
    (*

    Obtained via get_time_s in create

    • since 0.11
    *)
}

A request with method, path, host, headers, and a body, sent by a client.

The body is polymorphic because the request goes through several transformations. First it has no body, as only the request and headers are read; then it has a stream body; then the body might be entirely read as a string via read_body_full.

  • since 0.6 The field [query] was added and contains the query parameters in ["?foo=bar,x=y"]
  • since 0.6 The field [path_components] is the part of the path that precedes [query] and is split on ["/"].
  • since 0.11 the type is a private alias
  • since 0.11 the field [start_time] was added
val pp : Stdlib.Format.formatter -> string t -> unit

Pretty print the request and its body. The exact format of this printing is not specified.

val pp_ : Stdlib.Format.formatter -> _ t -> unit

Pretty print the request without its body. The exact format of this printing is not specified.

val headers : _ t -> Headers.t

List of headers of the request, including "Host".

val get_header : ?f:(string -> string) -> _ t -> string -> string option

get_header req h looks up header h in req. It returns None if the header is not present. This is case insensitive and should be used rather than looking up h verbatim in headers.

val get_header_int : _ t -> string -> int option

Same as get_header but also performs a string to integer conversion.

val set_header : string -> string -> 'a t -> 'a t

set_header k v req sets k: v in the request req's headers.

val update_headers : (Headers.t -> Headers.t) -> 'a t -> 'a t

Modify headers using the given function.

  • since 0.11
val set_body : 'a -> _ t -> 'a t

set_body b req returns a new query whose body is b.

  • since 0.11
val host : _ t -> string

Host field of the request. It also appears in the headers.

val meth : _ t -> Meth.t

Method for the request.

val path : _ t -> string

Request path.

val query : _ t -> (string * string) list

Decode the query part of the path field.

  • since 0.4
val body : 'b t -> 'b

Request body, possibly empty.

val start_time : _ t -> float

time stamp (from Unix.gettimeofday) after parsing the first line of the request

  • since 0.11
val limit_body_size : max_size:int -> byte_stream t -> byte_stream t

Limit the body size to max_size bytes, or return a 413 error.

  • since 0.3
val read_body_full : - ?buf:Tiny_httpd_buf.t -> - ?buf_size:int -> - byte_stream t -> - string t

Read the whole body into a string. Potentially blocking.

  • parameter buf_size

    initial size of underlying buffer (since 0.11)

  • parameter buf

    the initial buffer (since NEXT_RELEASE)

\ No newline at end of file diff --git a/dev/tiny_httpd/Tiny_httpd_server/Response/index.html b/dev/tiny_httpd/Tiny_httpd_server/Response/index.html deleted file mode 100644 index 1ead6ece..00000000 --- a/dev/tiny_httpd/Tiny_httpd_server/Response/index.html +++ /dev/null @@ -1,26 +0,0 @@ - -Response (tiny_httpd.Tiny_httpd_server.Response)

Module Tiny_httpd_server.Response

type body = [
  1. | `String of string
  2. | `Stream of byte_stream
  3. | `Writer of Tiny_httpd_io.Writer.t
  4. | `Void
]

Body of a response, either as a simple string, or a stream of bytes, or nothing (for server-sent events notably).

  • `String str replies with a body set to this string, and a known content-length.
  • `Stream str replies with a body made from this string, using chunked encoding.
  • `Void replies with no body.
  • `Writer w replies with a body created by the writer w, using a chunked encoding. It is available since NEXT_RELEASE.
type t = private {
  1. code : Response_code.t;
    (*

    HTTP response code. See Response_code.

    *)
  2. headers : Headers.t;
    (*

    Headers of the reply. Some will be set by Tiny_httpd automatically.

    *)
  3. body : body;
    (*

    Body of the response. Can be empty.

    *)
}

A response to send back to a client.

val set_body : body -> t -> t

Set the body of the response.

  • since 0.11
val set_header : string -> string -> t -> t

Set a header.

  • since 0.11
val update_headers : (Headers.t -> Headers.t) -> t -> t

Modify headers.

  • since 0.11
val set_headers : Headers.t -> t -> t

Set all headers.

  • since 0.11
val set_code : Response_code.t -> t -> t

Set the response code.

  • since 0.11
val make_raw : ?headers:Headers.t -> code:Response_code.t -> string -> t

Make a response from its raw components, with a string body. Use "" to not send a body at all.

val make_raw_stream : - ?headers:Headers.t -> - code:Response_code.t -> - byte_stream -> - t

Same as make_raw but with a stream body. The body will be sent with the chunked transfer-encoding.

val make_void : ?headers:Headers.t -> code:int -> unit -> t

Return a response without a body at all.

  • since 0.13
val make : - ?headers:Headers.t -> - ?code:int -> - (body, Response_code.t * string) Stdlib.result -> - t

make r turns a result into a response.

  • make (Ok body) replies with 200 and the body.
  • make (Error (code,msg)) replies with the given error code and message as body.
val make_string : - ?headers:Headers.t -> - ?code:int -> - (string, Response_code.t * string) Stdlib.result -> - t

Same as make but with a string body.

val make_writer : - ?headers:Headers.t -> - ?code:int -> - (Tiny_httpd_io.Writer.t, Response_code.t * string) Stdlib.result -> - t

Same as make but with a writer body.

val make_stream : - ?headers:Headers.t -> - ?code:int -> - (byte_stream, Response_code.t * string) Stdlib.result -> - t

Same as make but with a stream body.

val fail : - ?headers:Headers.t -> - code:int -> - ('a, unit, string, t) Stdlib.format4 -> - 'a

Make the current request fail with the given code and message. Example: fail ~code:404 "oh noes, %s not found" "waldo".

val fail_raise : code:int -> ('a, unit, string, 'b) Stdlib.format4 -> 'a

Similar to fail but raises an exception that exits the current handler. This should not be used outside of a (path) handler. Example: fail_raise ~code:404 "oh noes, %s not found" "waldo"; never_executed()

val pp : Stdlib.Format.formatter -> t -> unit

Pretty print the response. The exact format is not specified.

\ No newline at end of file diff --git a/dev/tiny_httpd/Tiny_httpd_server/Response_code/index.html b/dev/tiny_httpd/Tiny_httpd_server/Response_code/index.html deleted file mode 100644 index 6e84933a..00000000 --- a/dev/tiny_httpd/Tiny_httpd_server/Response_code/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Response_code (tiny_httpd.Tiny_httpd_server.Response_code)

Module Tiny_httpd_server.Response_code

type t = int

A standard HTTP code.

https://tools.ietf.org/html/rfc7231#section-6

val ok : t

The code 200

val not_found : t

The code 404

val descr : t -> string

A description of some of the error codes. NOTE: this is not complete (yet).

\ No newline at end of file diff --git a/dev/tiny_httpd/Tiny_httpd_server/Route/index.html b/dev/tiny_httpd/Tiny_httpd_server/Route/index.html deleted file mode 100644 index 25f6f090..00000000 --- a/dev/tiny_httpd/Tiny_httpd_server/Route/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Route (tiny_httpd.Tiny_httpd_server.Route)

Module Tiny_httpd_server.Route

type ('a, 'b) comp

An atomic component of a path

type ('a, 'b) t

A route, composed of path components

val int : (int -> 'a, 'a) comp

Matches an integer.

val string : (string -> 'a, 'a) comp

Matches a string not containing '/' and binds it as is.

val string_urlencoded : (string -> 'a, 'a) comp

Matches a URL-encoded string, and decodes it.

val exact : string -> ('a, 'a) comp

exact "s" matches "s" and nothing else.

val return : ('a, 'a) t

Matches the empty path.

val rest_of_path : (string -> 'a, 'a) t

Matches a string, even containing '/'. This will match the entirety of the remaining route.

  • since 0.7
val rest_of_path_urlencoded : (string -> 'a, 'a) t

Matches a string, even containing '/', an URL-decode it. This will match the entirety of the remaining route.

  • since 0.7
val (@/) : ('a, 'b) comp -> ('b, 'c) t -> ('a, 'c) t

comp / route matches "foo/bar/…" iff comp matches "foo", and route matches "bar/…".

val exact_path : string -> ('a, 'b) t -> ('a, 'b) t

exact_path "foo/bar/..." r is equivalent to exact "foo" @/ exact "bar" @/ ... @/ r

  • since 0.11 *
val pp : Stdlib.Format.formatter -> (_, _) t -> unit

Print the route.

  • since 0.7
val to_string : (_, _) t -> string

Print the route.

  • since 0.7
\ No newline at end of file diff --git a/dev/tiny_httpd/Tiny_httpd_server/module-type-IO_BACKEND/index.html b/dev/tiny_httpd/Tiny_httpd_server/module-type-IO_BACKEND/index.html deleted file mode 100644 index a012de2f..00000000 --- a/dev/tiny_httpd/Tiny_httpd_server/module-type-IO_BACKEND/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -IO_BACKEND (tiny_httpd.Tiny_httpd_server.IO_BACKEND)

Module type Tiny_httpd_server.IO_BACKEND

A backend that provides IO operations, network operations, etc.

This is used to decouple tiny_httpd from the scheduler/IO library used to actually open a TCP server and talk to clients. The classic way is based on Unix and blocking IOs, but it's also possible to use an OCaml 5 library using effects and non blocking IOs.

val init_addr : unit -> string

Initial TCP address

val init_port : unit -> int

Initial port

val get_time_s : unit -> float

Obtain the current timestamp in seconds.

val tcp_server : unit -> Tiny_httpd_io.TCP_server.builder

TCP server builder, to create servers that can listen on a port and handle clients.

\ No newline at end of file diff --git a/dev/tiny_httpd/Tiny_httpd_server/module-type-SERVER_SENT_GENERATOR/index.html b/dev/tiny_httpd/Tiny_httpd_server/module-type-SERVER_SENT_GENERATOR/index.html deleted file mode 100644 index 7f729f5c..00000000 --- a/dev/tiny_httpd/Tiny_httpd_server/module-type-SERVER_SENT_GENERATOR/index.html +++ /dev/null @@ -1,8 +0,0 @@ - -SERVER_SENT_GENERATOR (tiny_httpd.Tiny_httpd_server.SERVER_SENT_GENERATOR)

Module type Tiny_httpd_server.SERVER_SENT_GENERATOR

A server-side function to generate of Server-sent events.

See the w3c page and this blog post.

val set_headers : Headers.t -> unit

Set headers of the response. This is not mandatory but if used at all, it must be called before any call to send_event (once events are sent the response is already sent too).

val send_event : - ?event:string -> - ?id:string -> - ?retry:string -> - data:string -> - unit -> - unit

Send an event from the server. If data is a multiline string, it will be sent on separate "data:" lines.

val close : unit -> unit

Close connection.

  • since 0.11
\ No newline at end of file