I’d like to announce the release of the first alpha version of the new cohttp
. If you are not familiar with it, cohttp
is an OCaml library for creating HTTP clients and servers. It has a portable HTTP parser, and implementations using various asynchronous programming libraries.
This experimental release introduces a number of changes in cohttp’s internals and in the libraries provided. In particular:
- the new
http
library provides essential type definitions used incohttp
and also includes a new, extremely fast, http parser. The library is designed to have practically no dependencies and make it easy for other packages to easily interoperate with cohttp. -
cohttp-server-lwt-unix
is a new lwt server backend that does not rely on conduit and uses direct lwt-io access. This should resolve most of the latency issues encountered with the oldcohttp-lwt-unix
library. -
cohttp-curl
is a newlibcurl
-based (viaocurl
) library, also providing anlwt
and anasync
backend. -
cohttp-eio
useseio
to leverage new features from multicore ocaml, it also include new very fast parser to fully benefit from eio at all levels.
All of this comes with a large number of fixed bugs, improved testing, new long-awaited features (like the http cache for cohttp-lwt-unix
) and lots of internal refactoring and cleanup.
We would like to thank @rgrinberg @mefyl @anuragsoni @BikalGurung and all the people that contributed with issues, discussions, PRs and design ideas leading to this release.
LINKS
- Project page: GitHub - mirage/ocaml-cohttp: An OCaml library for HTTP clients and servers using Lwt or Async
- Documentation for the alpha version needs to be generated locally with
dune build @doc
CHANGES
- cohttp-eio: ensure “Host” header is the first header in http client requests (bikallem cohttp-eio(client): Ensure “Host” header is the first header in requests mirage/ocaml-cohttp#939)
- cohttp-eio: add TE header in client. Check TE header is server (bikallem Add TE header in client. Check TE header in server mirage/ocaml-cohttp#941)
- cohttp-eio: add User-Agent header to request from Client (bikallem cohttp-eio(client): add User-Agent header mirage/ocaml-cohttp#940)
- cohttp-eio: add Content-Length header to request/response (bikallem cohttp-eio: Add Content-Length header to request/response mirage/ocaml-cohttp#929)
- cohttp-eio: add cohttp-eio client api - Cohttp_eio.Client (bikallem cohttp-eio Client module mirage/ocaml-cohttp#879)
- http: add requires_content_length function for requests and responses (bikallem cohttp-eio Client module mirage/ocaml-cohttp#879)
- cohttp-eio: use Eio.Buf_write and improve server API (talex5 cohttp-eio: improve server API mirage/ocaml-cohttp#887)
- cohttp-eio: update to Eio 0.3 (talex5 Update for Eio 0.3 mirage/ocaml-cohttp#886)
- cohttp-eio: convert to Eio.Buf_read (talex5 cohttp-eio: use Eio.Buf_read mirage/ocaml-cohttp#882)
- cohttp lwt client: Connection cache and explicit pipelining (madroach Explicit pipelining and connection cache mirage/ocaml-cohttp#853)
- http: add Http.Request.make and simplify Http.Response.make (bikallem mseri http: add Request.make mirage/ocaml-cohttp#878)
- http: add pretty printer functions (bikallem http: add pretty printer functions mirage/ocaml-cohttp#880)
- New eio based client and server on top of the http library (bikallem RFC: eio-only version of cohttp mirage/ocaml-cohttp#857)
- New curl based clients (rgrinberg feature: Curl Based client mirage/ocaml-cohttp#813)
- cohttp-curl-lwt for an Lwt backend
- cohttp-curl-async for an Async backend
- Completely new Parsing layers for servers (anuragsoni Use new request parser mirage/ocaml-cohttp#819)
- Cohttp now uses an optimized parser for requests.
- The new parser produces much less temporary buffers during read operations
in servers.
- Faster header comparison (gasche cohttp.headers: faster faster comparison mirage/ocaml-cohttp#818)
- Introduce http package containing common signatures and structures useful for
compatibility with cohttp - and no dependencies (rgrinberg feature: introduce http package mirage/ocaml-cohttp#812) - async(server): allow reading number of active connections (anuragsoni async(server): allow reading number of active connections mirage/ocaml-cohttp#809)
- Various internal refactors (rgrinberg, mseri, fix: fast comparison of request/response mirage/ocaml-cohttp#802, feature: introduce http package mirage/ocaml-cohttp#812, http, cohttp: refactor Header module tests mirage/ocaml-cohttp#820, refactor: remove some Stringext usage mirage/ocaml-cohttp#800, refactor: explicit signature for async mirage/ocaml-cohttp#799,
refactor: stop relying on name mangling mirage/ocaml-cohttp#797) - http (all cohttp server backends): Consider the connection header in response
in addition to the request when deciding on whether to keep a connection
alive (anuragsoni, http: Consider the user provided response when considering connection keep-alive mirage/ocaml-cohttp#843)- The user provided Response can contain a connection header. That header
will also be considered in addition to the connection header in requests
when deciding whether to use keep-alive. This allows a handler to decide to
close a connection even if the client requested a keep-alive in the
request.
- The user provided Response can contain a connection header. That header
- async(server): allow creating a server without using conduit (anuragsoni Allow creating cohttp-async servers with existing reader/writers mirage/ocaml-cohttp#839)
- Add
Cohttp_async.Server.Expert.create
and
Cohttp_async.Server.Expert.create_with_response_action
that can be used to
create a server without going through Conduit. This allows creating an
async TCP server using the Tcp module fromAsync_unix
and lets the user
have more control over how theReader.t
andWriter.t
are created.
- Add
- http(header): faster
to_lines
andto_frames
implementation (mseri bench(http): optimize to_frames and to_lines functions mirage/ocaml-cohttp#847) - cohttp(cookies): use case-insensitive comparison to check for
set-cookies
(mseri Cookies: case-insensitive check of set-cookies mirage/ocaml-cohttp#858) - New lwt based server implementation:
cohttp-server-lwt-unix
: this new implementation does not depend on conduit and has a simpler and
more flexible API - async: Adapt cohttp-curl-async to work with core_unix.
BREAKING CHANGES
- refactor: move opam metadata to dune-project (rgrinberg refactor: move opam metadata to dune-project mirage/ocaml-cohttp#811)
- refactor: deprecate Cohttp_async.Io (rgrinberg refactor: deprecate Cohttp_async.Io mirage/ocaml-cohttp#807)
- fix: move more internals to Private (rgrinberg fix: move more internals to Private mirage/ocaml-cohttp#806)
- fix: deprecate transfer encoding field (rgrinberg fix: deprecate transfer encoding field mirage/ocaml-cohttp#805)
- refactor: deprecate Cohttp_async.Body_raw (rgrinberg refactor: deprecate Cohttp_async.Body_raw mirage/ocaml-cohttp#804)
- fix: deprecate more aliases (rgrinberg fix: deprecate more aliases mirage/ocaml-cohttp#803)
- refactor: deprecate connection value(rgrinberg refactor: deprecate connection value mirage/ocaml-cohttp#798)
- refactor: deprecate using attributes (rgrinberg refactor: deprecate using attributes mirage/ocaml-cohttp#796)
- cleanup: remove cohttp-{curl,server}-async (rgrinberg fix: stop installing binaries mirage/ocaml-cohttp#904)
- cleanup: remove cohttp-{curl,server,proxy}-lwt (rgrinberg fix: stop installing binaries mirage/ocaml-cohttp#904)
- fix: all parsers now follow the spec and require
\r\n
endings.
Previously, the\r
was optional. (rgrinberg, fix: require \r\n in all parsers mirage/ocaml-cohttp#921) -
cohttp-lwt-jsoo
: do not instantiateXMLHttpRequest
object on boot (mefyl Do not systematically create a XMLHttpRequest object. mirage/ocaml-cohttp#922)