Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. OCaml
  3. ocaml-cohttp

ocaml-cohttp

NOASSERTIONOCamlv6.2.1

An OCaml library for building HTTP clients and servers with support for multiple asynchronous backends including Lwt, Async, and Eio.

GitHubGitHub
769 stars181 forks0 contributors

What is ocaml-cohttp?

ocaml-cohttp is a comprehensive OCaml library for creating HTTP clients and servers. It provides a portable, dependency-free HTTP parser and supports multiple asynchronous backends like Lwt, Async, Eio, and Js_of_ocaml, enabling deployment across diverse targets from UNIX systems to MirageOS unikernels and JavaScript compilation.

Target Audience

OCaml developers building HTTP-based applications, including those targeting web services, MirageOS unikernels, or JavaScript environments via Js_of_ocaml. It's suitable for projects requiring flexible concurrency models and cross-platform compatibility.

Value Proposition

Developers choose ocaml-cohttp for its portability, minimal dependencies, and support for multiple asynchronous libraries, allowing them to select the best backend for their specific use case while maintaining a consistent HTTP interface. Its extensible architecture and included utility binaries for testing further streamline development.

Overview

An OCaml library for HTTP clients and servers using Lwt or Async

Use Cases

Best For

  • Building HTTP servers and clients in OCaml with support for multiple asynchronous backends like Lwt, Async, and Eio.
  • Developing applications for MirageOS unikernels that require HTTP communication capabilities.
  • Compiling OCaml HTTP libraries to JavaScript via Js_of_ocaml for web-based projects.
  • Creating cross-platform HTTP tools that run on UNIX systems, unikernels, and in JavaScript environments.
  • Implementing custom HTTP backends or resolvers, such as for Docker socket communication or other specialized protocols.
  • Testing and debugging HTTP interactions with included curl-like client and simple server binaries.

Not Ideal For

  • Projects requiring built-in support for multipart form data or session management without external dependencies
  • Teams seeking a batteries-included web framework with pre-built routing and middleware
  • Simple HTTP use cases where a single, lightweight async backend would suffice without configuration overhead

Pros & Cons

Pros

Portable HTTP Parser

The parser is fast and dependency-free, enabling easy interoperability with other OCaml packages and simplifying integration.

Flexible Async Backends

Supports Lwt, Async, Eio, and Js_of_ocaml, allowing developers to choose the concurrency model best suited for their platform, from UNIX to JavaScript.

Cross-Platform Deployment

Works on UNIX systems, MirageOS unikernels, and compiles to JavaScript via Js_of_ocaml, making it versatile for diverse target environments.

Extensible Architecture

The IO signature enables easy implementation of custom backends, as demonstrated in the Docker socket client example for specialized resolvers.

Cons

Missing Common Features

Multipart form data and session management are not built-in, requiring integration with external libraries like multipart_form or ocaml-session, increasing setup complexity.

Manual Redirect Handling

HTTP redirects are not automatically managed; developers must implement custom logic, as admitted in the README with tutorial examples for both Lwt and Async backends.

Backend Configuration Overhead

With multiple async backends available, selecting and configuring the right one can be daunting, especially for newcomers to OCaml's concurrency ecosystem.

Frequently Asked Questions

Quick Stats

Stars769
Forks181
Contributors0
Open Issues91
Last commit15 days ago
CreatedSince 2009

Tags

#asynchronous-programming#http-server#mirageos#unix#http#async#network-programming#web-development#http-client#ocaml

Built With

A
Async
O
OCaml
l
libcurl

Included in

OCaml3.1k
Auto-fetched 7 hours ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub