package bhttp

  1. Overview
  2. Docs
Binary Representation of HTTP Messages (RFC 9292) for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

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

doc/index.html

bhttp

bhttp is a codec for the binary representation of HTTP messages (RFC 9292): requests and responses in both framings, with informational responses, trailers, padding, and truncation. It has no dependencies and performs no I/O.

The library is unaudited and not production-ready. It is intended for interoperability review.

Entry points

A message is a record of strings and of pairs of strings, which the types of any HTTP library convert to and from in a few lines:

  let request =
    Bhttp.Request.make ~meth:"GET" ~authority:"example.com" ~path:"/" ()
  in
  match Bhttp.Request.encode request with
  | Ok encoded -> Bhttp.Request.decode encoded = Ok request
  | Error e -> failwith (Bhttp.Error.to_string e)

Bhttp.Request and Bhttp.Response encode and decode one kind of message, and Bhttp.Message either kind. Decoding accepts what RFC 9292 allows an encoder to vary (the size of an integer, missing empty sections at the end, zero padding) and rejects what it makes invalid; field names come back in lowercase. Encoding refuses what decoding would reject.

Modules

  • Bhttp.Request Binary HTTP requests (RFC 9292 Sections 3.1, 3.2, and 3.4).
  • Bhttp.Response Binary HTTP responses (RFC 9292 Sections 3.1, 3.2, and 3.5).
  • Bhttp.Message Binary HTTP messages of either kind (RFC 9292 Section 3).
  • Bhttp.Field Field lines (RFC 9292 Section 3.6).
  • Bhttp.Framing Framing indicator (RFC 9292 Section 3.3).
  • Bhttp.Varint Variable-length integers (RFC 9000 Section 16), as used by every length and numeric value of RFC 9292.
  • Bhttp.Error Errors returned by the public API. Messages describe classes of invalid input and never contain field values or message content.
  • Bhttp.Hex Lowercase hexadecimal encoding.

Guides