package orsetto

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

General syntax of the Uniform Resource Identifier (URI)

Overview

This module implements operations on the general syntax of Uniform Resource Identifiers (URI) according to RFC 3986, as well as convenience functions for manipulating their components. Some functions are also provided for conversion to and from strings for presentation.

Types

The private types below comprise the structure of generic URI values in syntax-normalized form (see RFC 3986, section 6.2.2).

type host = ..

The extensible sum type of "host" components of hierarchical URI's. Values of the cases of this type defined in this module are syntax-normalized. In particular, the ASCII letter characters present in "scheme" and "host" components are always lower case (except for the 'zoneid' field in IPv6 addresses).

type host += private
  1. | H_name of string

Host name (RFC 3986).

type host += private
  1. | H_ipv4 of {
    1. address : string;
    }

IPv4 address literal (RFC 3986)

type host += private
  1. | H_ipv6 of {
    1. address : string;
    2. zoneid : string option;
    }

IPv6 address literal with optional zone identifier (RFC 3986,6874)

type host += private
  1. | H_ip_future of {
    1. version : int;
    2. address : string;
    }

Future IP address literal (RFC 3986)

type authority = private
  1. | Authority of {
    1. user : string option;
    2. host : host;
    3. port : int option;
    }

The private type of "authority" components in hierarchical identifiers.

class type virtual basis = object ... end

The virtual class type inherited by all URI subtypes.

class type relative = object ... end

The class type of relative URI references.

class type absolute = object ... end

The class type of absolute URI bases.

class type generic = object ... end

The class type of generic URI.

type +'a container = private
  1. | Object of 'a
constraint 'a = basis

The private higher-order type of URI object containers.

The monomorphic type alias for generic URI objects.

type reference = private
  1. | Generic of generic container
  2. | Relative of relative container

The private type of URI references.

Scanners

These functions comprise a parser for the generic URI syntax defined in RFC 3986 (updated by errata and by RFC 6874).

Fields containing percent-encoded text are decoded first, then other syntax normalization functions are applied, e.g. case normalization, path segment list normalization, et cetera.

val scan_registry_name : string Cf_scan.ASCII.t

Use scan_registry_name to scan the "registry name" part of a host.

val scan_ipv4_address : string Cf_scan.ASCII.t

Use scan_ipv4_address to scan an IPv4 address literal.

val scan_ipv6_address : string Cf_scan.ASCII.t

Use scan_ipv6_address to scan an IPv6 address literal.

val scan_host : host Cf_scan.ASCII.t

Use scan_host to scan the "host" part of a URI authority.

val scan_authority : authority Cf_scan.ASCII.t

Use scan_authority to scan the "authority" part of a URI hierarchy.

val scan_generic : t Cf_scan.ASCII.t

Use scan_generic to scan a generic URI.

val scan_reference : reference Cf_scan.ASCII.t

Use scan_reference to scan a URI reference.

val of_string : string -> t

Use of_string s to decompose s into its URI structural value. Raises Invalid_argument if s is not valid generic URI syntax.

Emitters

These functions comprise a formatter that conforms to the generic URI syntax defined in RFC 3986 (updated by errata and by RFC 6874).

Unreserved characters are not percent-encoded. Reserved characters are only percent-encoded when the fields in which they appear are delimited by them.

val emit_host : host Cf_emit.To_buffer.t

Use emit_host b name to emit the "host" part of a URI authority.

val emit_authority : authority Cf_emit.To_buffer.t

Use emit_authority b authority to emit the "authority" part of a URI hierarchy.

val emit_generic : t Cf_emit.To_buffer.t

Use emit_generic b uri to emit a generic URI.

val emit_reference : reference Cf_emit.To_buffer.t

Use emit_reference b reference to emit a URI reference.

val to_string : t -> string

Use to_string uri to compose uri into its textual form.

Miscellaneous Functions
val resolve_aux : absolute container -> relative container -> t

Use resolve_aux b r to resolve r according to the base b.

val resolve : t -> reference -> t

Use resolve b r to resolve r according to the base b.

val percent_decode : char Seq.t -> char Seq.t

Use percent_decode s to transform the sequence s by decoding all the "percent-encoded" characters. Evaluation raises Failure if a '%' character appears without two hexadecimal digits immediately following.

val percent_encode : ?allow:(char -> bool) -> char Seq.t -> char Seq.t

Use percent_encode ?allow s to transform the sequence s into the equivalent "percent-encoded" sequence. Use ~allow to provide a function that returns true for those reserved characters to be left decoded in the resulting sequence. Unreserved characters are never percent encoded.

OCaml

Innovation. Community. Security.