Module Http.Query

Queries and query codecs.


type t = query

See query.

val empty : query

empty is the empty key-values map.

val is_empty : query -> bool

is_empty q is true if q is empty.

val mem : string -> query -> bool

mem k q is true iff key k is bound in q.

val def : string -> string -> query -> query

def k v q is q with k bound only to value v.

val add : string -> string -> query -> query

add k v q is q with k bound to find_all k q @ [v].

val remove : string -> query -> query

remove k q is q with k unbound.

val find : string -> query -> string option

find k q is the value of k's first binding in q, if any.

val find_all : string -> query -> string list

find_all k q are all the values bound to k or the empty list if k is unbound.

val fold : (string -> string -> 'a -> 'a) -> query -> 'a -> 'a

fold f q acc folds over all the key-value bindings. For keys with multiple values folds over them in the same order as given by find_all.


val decode : string -> query

decode s decodes the application/x-www-form-urlencoded s to a query. If a key is defined more than once, the first definition is returned by find and the left-to-right order preserved by find_all's list. The input string is not checked for UTF-8 validity.

val encode : query -> string

encode q encodes q to an application/x-www-form-urlencoded string.

val pp : Stdlib.Format.formatter -> query -> unit

pp is an unspecified formatter for queries.