package ohttp-cohttp-lwt

  1. Overview
  2. Docs
Oblivious HTTP (RFC 9458) clients, relays, and gateways over cohttp-lwt

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.1.2.tar.gz
md5=6a31dba01d9ee06d1b0115516439d8b0
sha512=c2739c32cf8d44b36ca565052f6b14feaf99a029115e8d94dcd469bd363f7dacd8e401a4ca07c0a3555f0fe5572a37516b489ddd945ee9acae4ceafc29e7dadb

doc/ohttp-cohttp-lwt/Ohttp_cohttp_lwt/index.html

Module Ohttp_cohttp_lwtSource

Oblivious HTTP over cohttp-lwt.

The client, relay, and gateway of Ohttp.Service, as calls and server callbacks of cohttp-lwt. The client, the relay, and the forwarding to targets make requests of their own, with any client of cohttp-lwt: that of cohttp-lwt-unix, or of cohttp-lwt-jsoo, or of a MirageOS unikernel.

module Ohttp_client = Ohttp_cohttp_lwt.Make (Cohttp_lwt_unix.Client)

(* A gateway for one target, over cohttp-lwt-unix. Build each handler once:
   the requests in flight are counted in [service]. *)
let gateway =
  Ohttp_cohttp_lwt.Gateway.handler service
    (Ohttp_client.Target.forward
       ~targets:[ ("example.com", Uri.of_string "https://example.com") ])

let () =
  Lwt_main.run
    (Cohttp_lwt_unix.Server.create
       (Cohttp_lwt_unix.Server.make ~callback:(fun _conn -> gateway) ()))

Contents are read in full: an encapsulated message is only opened when it is complete. Each read is limited (see Ohttp.Service.default_max_request_size and Ohttp.Service.default_max_response_size): what is longer is refused as soon as its declared length or what has arrived of it passes the limit, and the rest of it is read without being kept, since cohttp-lwt frees a connection only once its body has been read.

The callback of a cohttp-lwt server, without its connection: Cohttp_lwt_unix.Server.make ~callback:(fun _conn -> handler) ().

How a gateway gets a response for a request that it has decapsulated: from a target, with Make.Target.forward, from an application in the same process, with Target.of_handler, or in any other way.

Sourcemodule Gateway : sig ... end

A gateway: its key configurations, and the resource to which relays send Encapsulated Requests.

Sourcemodule Target : sig ... end

Targets that live in the same process as the gateway.

Sourcemodule Make (Http_client : Cohttp_lwt.S.Client) : sig ... end