From 99a82ba1afbcccb7eefe4994a81e2f9ef214ce0e Mon Sep 17 00:00:00 2001 From: c-cube Date: Mon, 15 Apr 2024 16:11:28 +0000 Subject: [PATCH] deploy: e1368525d808d7fbffb25b15da069054f0416f80 --- tiny_httpd/Tiny_httpd/index.html | 4 +++- tiny_httpd/Tiny_httpd_core/Server/Head_middleware/index.html | 2 ++ tiny_httpd/Tiny_httpd_core/Server/index.html | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 tiny_httpd/Tiny_httpd_core/Server/Head_middleware/index.html diff --git a/tiny_httpd/Tiny_httpd/index.html b/tiny_httpd/Tiny_httpd/index.html index 0c87bac0..a65e9ff0 100644 --- a/tiny_httpd/Tiny_httpd/index.html +++ b/tiny_httpd/Tiny_httpd/index.html @@ -49,7 +49,7 @@ echo: Accept: */* Content-Length: 10 Content-Type: application/x-www-form-urlencoded; - path="/echo"; body="howdy y'all"}

Tiny buffer implementation

These buffers are used to avoid allocating too many byte arrays when processing streams and parsing requests.

module Buf = Tiny_httpd_core.Buf

IO Abstraction

module IO = Tiny_httpd_core.IO

Logging

module Log = Tiny_httpd_core.Log

Utils

module Util = Tiny_httpd_core.Util

Resource pool

module Pool = Tiny_httpd_core.Pool

Static directory serving

module Dir = Tiny_httpd_unix.Dir
module type VFS = Tiny_httpd_unix.Dir.VFS

HTML combinators

module Html = Tiny_httpd_html

Main server types

module Request = Tiny_httpd_core.Request
module Response = Tiny_httpd_core.Response
module Response_code = Tiny_httpd_core.Response_code
module Route = Tiny_httpd_core.Route
module Headers = Tiny_httpd_core.Headers
module Meth = Tiny_httpd_core.Meth
module Server = Tiny_httpd_core.Server
Middlewares

A middleware can be inserted in a handler to modify or observe its behavior.

module Middleware = Server.Middleware
Main Server type

A HTTP server. See create for more details.

module type IO_BACKEND = Server.IO_BACKEND

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

val create_from : + path="/echo"; body="howdy y'all"}

Tiny buffer implementation

These buffers are used to avoid allocating too many byte arrays when processing streams and parsing requests.

module Buf = Tiny_httpd_core.Buf

IO Abstraction

module IO = Tiny_httpd_core.IO

Logging

module Log = Tiny_httpd_core.Log

Utils

module Util = Tiny_httpd_core.Util

Resource pool

module Pool = Tiny_httpd_core.Pool

Static directory serving

module Dir = Tiny_httpd_unix.Dir
module type VFS = Tiny_httpd_unix.Dir.VFS

HTML combinators

module Html = Tiny_httpd_html

Main server types

module Request = Tiny_httpd_core.Request
module Response = Tiny_httpd_core.Response
module Response_code = Tiny_httpd_core.Response_code
module Route = Tiny_httpd_core.Route
module Headers = Tiny_httpd_core.Headers
module Meth = Tiny_httpd_core.Meth
module Server = Tiny_httpd_core.Server
Middlewares

A middleware can be inserted in a handler to modify or observe its behavior.

  • since 0.11
module Middleware = Server.Middleware
module Head_middleware = Server.Head_middleware

A middleware that only considers the request's head+headers.

Main Server type

A HTTP server. See create for more details.

module type IO_BACKEND = Server.IO_BACKEND

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

val create_from : ?buf_size:int -> ?middlewares:([ `Encoding | `Stage of int ] * Middleware.t) list -> backend:(module IO_BACKEND) -> @@ -100,6 +100,7 @@ echo: ?accept: (unit Tiny_httpd_core.Request.t -> (unit, Tiny_httpd_core.Response_code.t * string) result) -> + ?middlewares:Head_middleware.t list -> t -> ('a, string Tiny_httpd_core.Request.t -> server_sent_generator -> unit) Tiny_httpd_core.Route.t -> @@ -108,6 +109,7 @@ echo: ?accept: (unit Tiny_httpd_core.Request.t -> (unit, Tiny_httpd_core.Response_code.t * string) result) -> + ?middlewares:Head_middleware.t list -> t -> ('a, upgrade_handler) Tiny_httpd_core.Route.t -> 'a -> diff --git a/tiny_httpd/Tiny_httpd_core/Server/Head_middleware/index.html b/tiny_httpd/Tiny_httpd_core/Server/Head_middleware/index.html new file mode 100644 index 00000000..94acc512 --- /dev/null +++ b/tiny_httpd/Tiny_httpd_core/Server/Head_middleware/index.html @@ -0,0 +1,2 @@ + +Head_middleware (tiny_httpd.Tiny_httpd_core.Server.Head_middleware)

Module Server.Head_middleware

A middleware that only considers the request's head+headers.

These middlewares are simpler than full Middleware.t and work in more contexts.

  • since NEXT_RELEASE
type t = {
  1. handle : 'a. 'a Request.t -> 'a Request.t;
}

A handler that takes the request, without its body, and possibly modifies it.

val to_middleware : t -> Middleware.t
diff --git a/tiny_httpd/Tiny_httpd_core/Server/index.html b/tiny_httpd/Tiny_httpd_core/Server/index.html index 75deb950..675c26b0 100644 --- a/tiny_httpd/Tiny_httpd_core/Server/index.html +++ b/tiny_httpd/Tiny_httpd_core/Server/index.html @@ -1,5 +1,5 @@ -Server (tiny_httpd.Tiny_httpd_core.Server)

Module Tiny_httpd_core.Server

HTTP server.

This module implements a very simple, basic HTTP/1.1 server using blocking IOs and threads.

It is possible to use a thread pool, see create's argument new_thread.

  • since 0.13

Middlewares

A middleware can be inserted in a handler to modify or observe its behavior.

  • since 0.11
module Middleware : sig ... end

Main Server type

type t

A HTTP server. See create for more details.

module type IO_BACKEND = sig ... end

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

val create_from : +Server (tiny_httpd.Tiny_httpd_core.Server)

Module Tiny_httpd_core.Server

HTTP server.

This module implements a very simple, basic HTTP/1.1 server using blocking IOs and threads.

It is possible to use a thread pool, see create's argument new_thread.

  • since 0.13

Middlewares

A middleware can be inserted in a handler to modify or observe its behavior.

  • since 0.11
module Middleware : sig ... end
module Head_middleware : sig ... end

A middleware that only considers the request's head+headers.

Main Server type

type t

A HTTP server. See create for more details.

module type IO_BACKEND = sig ... end

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

val create_from : ?buf_size:int -> ?middlewares:([ `Encoding | `Stage of int ] * Middleware.t) list -> backend:(module IO_BACKEND) -> @@ -30,11 +30,13 @@ 'a -> unit

Similar to add_route_handler, but where the body of the request is a stream of bytes that has not been read yet. This is useful when one wants to stream the body directly into a parser, json decoder (such as Jsonm) or into a file.

  • since 0.6

Server-sent events

EXPERIMENTAL: this API is not stable yet.

module type SERVER_SENT_GENERATOR = sig ... end

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

type server_sent_generator = (module SERVER_SENT_GENERATOR)

Server-sent event generator. This generates events that are forwarded to the client (e.g. the browser).

  • since 0.9
val add_route_server_sent_handler : ?accept:(unit Request.t -> (unit, Response_code.t * string) result) -> + ?middlewares:Head_middleware.t list -> t -> ('a, string Request.t -> server_sent_generator -> unit) Route.t -> 'a -> unit

Add a handler on an endpoint, that serves server-sent events.

The callback is given a generator that can be used to send events as it pleases. The connection is always closed by the client, and the accepted method is always GET. This will set the header "content-type" to "text/event-stream" automatically and reply with a 200 immediately. See server_sent_generator for more details.

This handler stays on the original thread (it is synchronous).

  • since 0.9

Upgrade handlers

These handlers upgrade the connection to another protocol.

  • since NEXT_RELEASE
module type UPGRADE_HANDLER = sig ... end

Handler that upgrades to another protocol.

type upgrade_handler = (module UPGRADE_HANDLER)
  • since NEXT_RELEASE
val add_upgrade_handler : ?accept:(unit Request.t -> (unit, Response_code.t * string) result) -> + ?middlewares:Head_middleware.t list -> t -> ('a, upgrade_handler) Route.t -> 'a ->