Up

module Transfer

: sig

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

#
type encoding =
# | Chunked
(*dynamic chunked encoding*)
# | Fixed of int64
(*fixed size content*)
# | Unknown

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

#
type chunk =
# | Chunk of string
(*chunk of data and not the end of stream*)
# | Final_chunk of string
(*the last chunk of data, so no more should be read*)
# | Done

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

#
val string_of_encoding : encoding -> string

Convert the encoding format to a human-readable string

#
val 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.

#
val encoding_of_sexp : Sexplib.Sexp.t -> encoding
#
val sexp_of_encoding : encoding -> Sexplib.Sexp.t
#
val chunk_of_sexp : Sexplib.Sexp.t -> chunk
#
val sexp_of_chunk : chunk -> Sexplib.Sexp.t
end