HTTP types: headers, status codes, methods, bodies, MIME types
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add missing READMEs; expand short ones

New READMEs for: ocaml-auth, ocaml-cose, ocaml-http, ocaml-osv,
ocaml-rego, ocaml-scitt, ocaml-sigstore, ocaml-vec3.

Expanded: ca-certs (7→40 lines), osrelease (8→45 lines).

Each includes: synopsis, installation, usage example, API overview,
and license. Skipped ocaml-cel and ocaml-chor (no code yet).

+52
+52
README.md
··· 1 + ## http -- HTTP types for OCaml 2 + 3 + Core HTTP types: headers, status codes, methods, bodies, MIME types, and 4 + responses. This library provides the shared type definitions used by HTTP 5 + client and server libraries, following 6 + [RFC 9110](https://datatracker.ietf.org/doc/html/rfc9110). 7 + 8 + Built on [Eio](https://github.com/ocaml-multicore/eio) for streaming bodies 9 + and file I/O. 10 + 11 + ## Installation 12 + 13 + ``` 14 + opam install http 15 + ``` 16 + 17 + ## Modules 18 + 19 + - `Body` -- request body construction (string, JSON, form, multipart, file, stream) 20 + - `Headers` -- case-insensitive header map with type-safe standard header names 21 + - `Status` -- HTTP status codes (1xx--5xx) per RFC 9110 22 + - `Method` -- HTTP methods (GET, POST, PUT, DELETE, ...) 23 + - `Response` -- HTTP response with status, headers, and streaming body 24 + - `Mime` -- MIME type detection and constants 25 + - `Cache_control` -- cache directive parsing per RFC 9111 26 + - `Huri` -- efficient URI serialization to `Eio.Buf_write` 27 + 28 + ## Quick Start 29 + 30 + ```ocaml 31 + (* Build a JSON body *) 32 + let body = Body.json {|{"name": "Alice"}|} 33 + 34 + (* Build headers *) 35 + let headers = 36 + Headers.empty 37 + |> Headers.set `Content_type "application/json" 38 + |> Headers.set `Authorization "Bearer token" 39 + |> Headers.set (`Other "X-Request-Id") "abc123" 40 + 41 + (* Multipart file upload *) 42 + let body = 43 + Body.multipart [ 44 + { name = "file"; filename = Some "doc.pdf"; 45 + content_type = Mime.pdf; 46 + content = `File Eio.Path.(fs / "doc.pdf") }; 47 + ] 48 + ``` 49 + 50 + ## License 51 + 52 + ISC