[ANN] http_async 0.2.0

I’d like to announce the initial release of http_async.

Http_async: provides a HTTP/1.1 web server for async.

The library started life as a wrapper around httpaf, but has evolved over time to be a standalone implementation of an HTTP/1.1 server. It implements its own parser that works on big strings and is reasonably fast. The library supports the common use-cases of connection pipelining, streaming request and response bodies. Servers can be run on both IP and Unix domain sockets, and ships with optional Core.Command entry points.

The implementation initially started as a testing ground for my I/o library shuttle, but I’ve been happy enough with the resulting api that I intend to support this as a standalone library moving forward. As far as performance is concerned, I always recommend doing your own tests with workloads that are closer to the intended use, but in my tests the performance seems very reasonable. There is a version of http_async that’s part of the http benchmarks run for the multicore project and the results looked fairly decent when compared to other single threaded runtimes (see Replace shuttle with http-async by anuragsoni · Pull Request #24 · ocaml-multicore/retro-httpaf-bench · GitHub for more details)

Hello World server

open! Core
open Async
open Http_async

let () =
  Command_unix.run
    (Server.run_command ~summary:"Hello world HTTP Server" (fun peer_addr _request ->
       return (Response.create `Ok, Body.Writer.string "Hello World")))
;;

The library doesn’t ship with any routers, or a middleware composition API with the intention that those will be layers that will live as a separate library. It should be easy to plug this into a third party routing library like ocaml-dispatch or routes. Some examples can be seen at: http_async/example at main · anuragsoni/http_async · GitHub and http_async/server_bench.ml at main · anuragsoni/http_async · GitHub and documentation is available online.

Install

To use the version published on opam:

opam install http_async

For the development version:

opam pin add http_async.dev git+https://github.com/anuragsoni/http_async.git

If you try the library and experience any issues, or have further questions, please report an issue on the Github Issue tracker.

Thanks,
Anurag

5 Likes