package cohttp

  1. Overview
  2. Docs

Accept-Encoding HTTP header parsing and generation

type q = int

Qualities are integers between 0 and 1000. A header with "q=0.7" corresponds to a quality of 700.

include sig ... end
val q_of_sexp : Sexplib.Sexp.t -> q
val sexp_of_q : q -> Sexplib.Sexp.t
type 'a qlist = (q * 'a) list

Lists, annotated with qualities.

include sig ... end
val qlist_of_sexp : (Sexplib.Sexp.t -> 'a) -> Sexplib.Sexp.t -> 'a qlist
val sexp_of_qlist : ('a -> Sexplib.Sexp.t) -> 'a qlist -> Sexplib.Sexp.t
val qsort : 'a qlist -> 'a qlist

Sort by quality, biggest first. Respect the initial ordering.

type pv =
  1. | T of string
  2. | S of string
include sig ... end
val pv_of_sexp : Sexplib.Sexp.t -> pv
val sexp_of_pv : pv -> Sexplib.Sexp.t
type p = string * pv
include sig ... end
val p_of_sexp : Sexplib.Sexp.t -> p
val sexp_of_p : p -> Sexplib.Sexp.t
type media_range =
  1. | MediaType of string * string
  2. | AnyMediaSubtype of string
  3. | AnyMedia
include sig ... end
val media_range_of_sexp : Sexplib.Sexp.t -> media_range
val sexp_of_media_range : media_range -> Sexplib.Sexp.t
type charset =
  1. | Charset of string
  2. | AnyCharset
include sig ... end
val charset_of_sexp : Sexplib.Sexp.t -> charset
val sexp_of_charset : charset -> Sexplib.Sexp.t
type encoding =
  1. | Encoding of string
  2. | Gzip
  3. | Compress
  4. | Deflate
  5. | Identity
  6. | AnyEncoding
include sig ... end
val encoding_of_sexp : Sexplib.Sexp.t -> encoding
val sexp_of_encoding : encoding -> Sexplib.Sexp.t
type language =
  1. | Language of string list
  2. | AnyLanguage

Basic language range tag. "en-gb" is represented as Language ["en"; "gb"].

include sig ... end
val language_of_sexp : Sexplib.Sexp.t -> language
val sexp_of_language : language -> Sexplib.Sexp.t
val media_ranges : string option -> (media_range * p list) qlist
val charsets : string option -> charset qlist
val encodings : string option -> encoding qlist
val languages : string option -> language qlist
val string_of_media_range : (media_range * (string * pv) list) -> q -> string
val string_of_charset : charset -> q -> string
val string_of_encoding : encoding -> q -> string
val string_of_language : language -> q -> string
val string_of_media_ranges : (media_range * p list) qlist -> string
val string_of_charsets : charset qlist -> string
val string_of_encodings : encoding qlist -> string
val string_of_languages : language qlist -> string
OCaml

Innovation. Community. Security.