package mechaml

  1. Overview
  2. Docs

Module Mechaml.CookiejarSource

Cookies management

Cookiejar is the module that stores and manages cookies. A Cookiejar stores the list of all cookies created by the Set-Cookie headers sent by the server. It is able to automatically extract cookies from server headers (see add_from_headers), or to select and add relevant coookies to the Cookie client header before sending an HTTP request (see add_to_headers).

It is mainly used by the Agent module internally, but can be used wherever one needs to manually edit the cookies sent by the agent.

Representation of a cookie

Sourcetype t
Sourceval empty : t

The empty cookie jar

Sourceval add : Cookie.t -> t -> t

Add a cookie to the jar

Sourceval remove : Cookie.t -> t -> t

Remove a cookie from the jar

Sourceval add_from_headers : Uri.t -> Cohttp.Header.t -> t -> t

Given a header received from a server, update the jar according to possible Set-Cookie HTTP headers

Sourceval add_to_headers : Uri.t -> Cohttp.Header.t -> t -> Cohttp.Header.t

Given a target URI, update the client HTTP headers with relevant cookies before sending to the server

Sourceval map : (Cookie.t -> Cookie.t) -> t -> t
Sourceval iter : (Cookie.t -> unit) -> t -> unit
Sourceval fold : (Cookie.t -> 'a -> 'a) -> t -> 'a -> 'a
Sourceval is_empty : t -> bool
OCaml

Innovation. Community. Security.