package ldp

  1. Overview
  2. Docs

Module Ldp.HttpSource

Providing high-level HTTP queries.

Sourcemodule Ldp = Rdf.Ldp
Sourceval user_agent : string ref

String added in query header "User-agent".

Sourcetype query_error = Cohttp.Code.meth * int * Types.meta
Sourcetype Types.error +=
  1. | Query_error of query_error
Sourceval string_of_query_error : query_error -> string
Sourceval container_types : Iri.Set.t

The set of known container types.

Sourceval type_is_container : Iri.t -> bool

type_is_container iri returns whether iri is a container type, comparing to known container_types.

Sourceval is_container : ?iri:Iri.t -> Rdf.Graph.graph -> bool

is_container ~iri g returns whether iri is a container, according to graph g. If iri is not provided, the name if the graph is used intead.

Sourceval response_metadata : Iri.t -> (Cohttp.Response.t * Cohttp_lwt.Body.t) -> Types.meta

response_metadata iri (resp, body) creates a Types.meta structure with the given iri and from the http response and body.

Sourceval parse_graph : ?g:Rdf.Graph.graph -> Iri.t -> Ct.t -> string -> (Rdf.Graph.graph, Types.error) result

parse_graph iri content_type body tries to parse graph in body according to the content_type. If no graph g is provided, a new one with name iri is created. The graph (the enriched graph or the created one) or an error is returned.

Abstraction of HTTP requests

Sourcemodule type Requests = sig ... end
Sourceexception Not_initialized of string
Sourceval dummy_requests : string -> (module Requests)

dummy_request name returns a module which can be used in applications instead of a normal Requests module, typically before some initializations. dbg does nothing and call will raise Not_initialized name.

Caching

Sourcemodule type Cache = sig ... end
Sourcetype cache_find_response =
  1. | Not_found
    (*

    The resource was not found in cache.

    *)
  2. | Found of Cohttp.Response.t * string
    (*

    The resource was found in cache, with the given response and body as string.

    *)
  3. | If_error of Cohttp.Response.t -> string -> (Cohttp.Response.t * string) Lwt.t
    (*

    The resource is in the cache, but it should be used only in case of error after performing the request.

    *)

The different ways the find function of a cache implementation can respond.

Sourcemodule type Cache_impl = sig ... end

Creates a cache from implementation of cache operations.

A cache caching nothing, i.e. key always returns None.

High-level HTTP

The high-level HTTP module created from a Requests implementation.

Sourcemodule type Http = sig ... end

Creates a Http module using the given cache.

Sourcemodule Http (_ : Requests) : Http

Specialized HTTP queries

These are queries used to send and receive data of a given content-type. The following module types and the Http_ct module can be used to create functions to perform such queries.

Sourcemodule type Ct_wrapper = sig ... end

Mapping values of a given content-type to and from strings.

Sourcemodule type Http_ct = sig ... end

The type of the module with specialized query functions.

Sourcemodule Http_ct (_ : Http) (W : Ct_wrapper) : Http_ct with type t = W.t

Creating a module to perform specialized queries over the given Http module. See the corresponding functions in Http for more information about arguments.

OCaml

Innovation. Community. Security.