package bytebuffer

  1. Overview
  2. Docs
Extensible buffers built on top of bigarrays

Install

Dune Dependency

Authors

Maintainers

Sources

h1-0.0.2.tbz
sha256=6de8da90c7442c69d3ff2d82c393804dae4e90fe3abd963a896e825669c95dfd
sha512=496184c91b228dd19fa2074ca091b887b0d148af4207ebedfbad8b95582a600f13ba61c2c68bd316a5f74e69c1b964f5c690f5b212b29b80235e23958969c12e

README.md.html

H1

h1 is a simple http 1.1 implementation. The core protocol layout doesn't enforce any concurrency strategry and as a result it is possible to provide small translation modules that can provide an Lwt or Async aware interface.

Warning

This is currently a proof-of-concept. There are many rough edges and probably many bugs. Use it at your own risk. That said, the approach seems to work well and in my initial tests the performance seems pretty decent. With some more effort it should be possible to get to a respectable state with extensive tests.

Features/Goals

  • Asynchronous pull based design

  • No I/O in the core library. Use it with any I/O paradigm (async, sync, threaded, etc)

Usage

HTTP Server

Example using async:

let run (sock : Fd.t) =
  let service (req, _body) =
    let target = Request.path req in
    let resp =
      Response.create
        ~headers:
          (Headers.of_list
             [ ("Content-Length", Int.to_string (Base_bigstring.length text)) ])
        `Ok
    in
    match target with
    | "/delay" ->
        let%map () = after Time.Span.millisecond in
        (resp, `Bigstring text)
    | _ -> return (resp, `Bigstring text)
  in
  let conn =
    H1_async.create sock ~read_buffer_size:(10 * 1024)
      ~write_buffer_size:(10 * 1024)
  in
  H1_async.run conn service

Todo

  • [x] Chunked Encoding

  • [ ] 0 copy streaming for bodies

  • [ ] Better error handling

  • [ ] Add docs

  • [ ] Http client implementation (This can be pushed till after a full working/tested/documented server implementation)

OCaml

Innovation. Community. Security.