package cohttp

  1. Overview
  2. Docs
An OCaml library for HTTP clients and servers

Install

dune-project
 Dependency

Authors

Maintainers

Sources

cohttp-2.5.8.tbz
sha256=2722477d1f5bb09e841debc125c30ff44f1b20cf8894b68cb48f2b6de092d25a
sha512=ce934a24c0e1eaf5dc674927b45277d461a13757d4c165a4a11811f9eb7b11b78b4560792ca430734d4e3a5b8791eee887d4eab2a0e9e30aa4a5864e833dd768

doc/cohttp/Cohttp/Transfer/index.html

Module Cohttp.TransferSource

Read and write the HTTP/1.1 transfer-encoding formats. Currently supported are chunked and content-length.

Sourcetype encoding =
  1. | Chunked
    (*

    dynamic chunked encoding

    *)
  2. | Fixed of int64
    (*

    fixed size content

    *)
  3. | Unknown
    (*

    unknown body size, which leads to best-effort

    *)

The encoding format detected from the transfer-encoding and content-length headers

Sourceval sexp_of_encoding : encoding -> Sexplib0.Sexp.t
Sourceval encoding_of_sexp : Sexplib0.Sexp.t -> encoding
Sourcetype chunk =
  1. | Chunk of string
    (*

    chunk of data and not the end of stream

    *)
  2. | Final_chunk of string
    (*

    the last chunk of data, so no more should be read

    *)
  3. | Done
    (*

    no more body data is present

    *)

A chunk of body that also signals if there to more to arrive

Sourceval sexp_of_chunk : chunk -> Sexplib0.Sexp.t
Sourceval chunk_of_sexp : Sexplib0.Sexp.t -> chunk
Sourceval string_of_encoding : encoding -> string

Convert the encoding format to a human-readable string

Sourceval has_body : encoding -> [ `No | `Unknown | `Yes ]

has_body encoding returns the appropriate variant that indicates whether the HTTP request or response has an associated body. It does not guess: instead Unknown is returned if there is no explicit association.