Skip to main content
Version: 2.5.x (dev)

Internet

harbor.http.register

Low-level harbor handler registration. Overridden in standard library.

Type:

(?port : int, ?transport : http_transport
.{default_port : int, name : string, protocol : string}, ?method : string,
regexp,
((
{
data : (?timeout : float) -> string,
headers : [string * string],
http_version : string,
method : string,
path : string,
query : [string * string],
socket : socket
.{
close : () -> unit,
closed : () -> bool,
non_blocking : (bool) -> unit,
read : ((?timeout : float?) -> string)
.{wait : (?timeout : float?, (() -> unit)) -> unit
},
type : string,
write : ((?timeout : float?, string) -> unit)
.{wait : (?timeout : float?, (() -> unit)) -> unit
}
}
}) -> {string}?)) -> unit

Arguments:

  • port (of type int, which defaults to 8000): Port to serve.
  • transport (of type http_transport.{default_port : int, name : string, protocol : string}, which defaults to <unix_transport>.{default_port=80, protocol="http", name="unix"}): Http transport. Use http.transport.ssl or http.transport.secure_transport, when available, to enable HTTPS output
  • method (of type string, which defaults to "GET"): Accepted method ("GET" / "POST" / "PUT" / "DELETE" / "HEAD" / "OPTIONS").
  • (unlabeled) (of type regexp): path to serve.
  • (unlabeled) (of type ( { data : (?timeout : float) -> string, headers : [string * string], http_version : string, method : string, path : string, query : [string * string], socket : socket .{ close : () -> unit, closed : () -> bool, non_blocking : (bool) -> unit, read : ((?timeout : float?) -> string) .{wait : (?timeout : float?, (() -> unit)) -> unit }, type : string, write : ((?timeout : float?, string) -> unit) .{wait : (?timeout : float?, (() -> unit)) -> unit } } }) -> {string}?): Handler function

harbor.remove

Remove a registered handler on the harbor.

Type:

(?port : int, ?method : string, regexp) -> unit

Arguments:

  • port (of type int, which defaults to 8000): Port to serve.
  • method (of type string, which defaults to "GET"): Method served.
  • (unlabeled) (of type regexp): URI served.

host.of_internet_address

Find a host by internet address

Type:

(internet_address) ->
{
addresses : [internet_address.{is_ipv6 : bool, to_string : () -> string}],
aliases : [string],
domain : socket_domain,
name : string}?

Arguments:

  • (unlabeled) (of type internet_address)

host.of_name

Find a host by name

Type:

(string) ->
{
addresses : [internet_address.{is_ipv6 : bool, to_string : () -> string}],
aliases : [string],
domain : socket_domain,
name : string}?

Arguments:

  • (unlabeled) (of type string): hostname

http.delete

Perform a full http DELETE request.

Type:

(?headers : [string * string], ?http_version : string?, ?redirect : bool,
?timeout : float?, ?normalize_url : bool?, string) -> unit

Arguments:

  • headers (of type [string * string], which defaults to []): Additional headers.
  • http_version (of type string?, which defaults to null): Http request version.
  • redirect (of type bool, which defaults to true): Perform redirections if needed.
  • timeout (of type float?, which defaults to 10.0): Timeout for network operations in seconds.
  • normalize_url (of type bool?, which defaults to null): Normalize url, replacing spaces with %20 and more. Defaults to settings.http.normalize_url when null.
  • (unlabeled) (of type string): Requested URL, e.g. "http://www.liquidsoap.info/".

Methods:

  • headers (of type [string * string]): HTTP headers.
  • http_version (of type string): Version of the HTTP protocol.
  • status_code (of type int): Status code.
  • status_message (of type string): Status message.

http.delete.stream

Perform a full http DELETE request.

Type:

(?headers : [string * string], ?http_version : string?, ?redirect : bool,
?timeout : float?, ?normalize_url : bool?, string,
on_body_data : ((string?) -> unit)) -> unit

Arguments:

  • headers (of type [string * string], which defaults to []): Additional headers.
  • http_version (of type string?, which defaults to null): Http request version.
  • redirect (of type bool, which defaults to true): Perform redirections if needed.
  • timeout (of type float?, which defaults to 10.0): Timeout for network operations in seconds.
  • normalize_url (of type bool?, which defaults to null): Normalize url, replacing spaces with %20 and more. Defaults to settings.http.normalize_url when null.
  • (unlabeled) (of type string): Requested URL, e.g. "http://www.liquidsoap.info/".
  • on_body_data (of type (string?) -> unit): function called when receiving response body data. null or "" means that all the data has been passed.

Methods:

  • headers (of type [string * string]): HTTP headers.
  • http_version (of type string): Version of the HTTP protocol.
  • status_code (of type int): Status code.
  • status_message (of type string): Status message.

http.get

Perform a full http GET request.

Type:

(?headers : [string * string], ?http_version : string?, ?redirect : bool,
?timeout : float?, ?normalize_url : bool?, string) -> string

Arguments:

  • headers (of type [string * string], which defaults to []): Additional headers.
  • http_version (of type string?, which defaults to null): Http request version.
  • redirect (of type bool, which defaults to true): Perform redirections if needed.
  • timeout (of type float?, which defaults to 10.0): Timeout for network operations in seconds.
  • normalize_url (of type bool?, which defaults to null): Normalize url, replacing spaces with %20 and more. Defaults to settings.http.normalize_url when null.
  • (unlabeled) (of type string): Requested URL, e.g. "http://www.liquidsoap.info/".

Methods:

  • headers (of type [string * string]): HTTP headers.
  • http_version (of type string): Version of the HTTP protocol.
  • status_code (of type int): Status code.
  • status_message (of type string): Status message.

http.get.stream

Perform a full http GET request.

Type:

(?headers : [string * string], ?http_version : string?, ?redirect : bool,
?timeout : float?, ?normalize_url : bool?, string,
on_body_data : ((string?) -> unit)) -> unit

Arguments:

  • headers (of type [string * string], which defaults to []): Additional headers.
  • http_version (of type string?, which defaults to null): Http request version.
  • redirect (of type bool, which defaults to true): Perform redirections if needed.
  • timeout (of type float?, which defaults to 10.0): Timeout for network operations in seconds.
  • normalize_url (of type bool?, which defaults to null): Normalize url, replacing spaces with %20 and more. Defaults to settings.http.normalize_url when null.
  • (unlabeled) (of type string): Requested URL, e.g. "http://www.liquidsoap.info/".
  • on_body_data (of type (string?) -> unit): function called when receiving response body data. null or "" means that all the data has been passed.

Methods:

  • headers (of type [string * string]): HTTP headers.
  • http_version (of type string): Version of the HTTP protocol.
  • status_code (of type int): Status code.
  • status_message (of type string): Status message.

http.head

Perform a full http HEAD request.

Type:

(?headers : [string * string], ?http_version : string?, ?redirect : bool,
?timeout : float?, ?normalize_url : bool?, string) -> unit

Arguments:

  • headers (of type [string * string], which defaults to []): Additional headers.
  • http_version (of type string?, which defaults to null): Http request version.
  • redirect (of type bool, which defaults to true): Perform redirections if needed.
  • timeout (of type float?, which defaults to 10.0): Timeout for network operations in seconds.
  • normalize_url (of type bool?, which defaults to null): Normalize url, replacing spaces with %20 and more. Defaults to settings.http.normalize_url when null.
  • (unlabeled) (of type string): Requested URL, e.g. "http://www.liquidsoap.info/".

Methods:

  • headers (of type [string * string]): HTTP headers.
  • http_version (of type string): Version of the HTTP protocol.
  • status_code (of type int): Status code.
  • status_message (of type string): Status message.

http.head.stream

Perform a full http HEAD request.

Type:

(?headers : [string * string], ?http_version : string?, ?redirect : bool,
?timeout : float?, ?normalize_url : bool?, string,
on_body_data : ((string?) -> unit)) -> unit

Arguments:

  • headers (of type [string * string], which defaults to []): Additional headers.
  • http_version (of type string?, which defaults to null): Http request version.
  • redirect (of type bool, which defaults to true): Perform redirections if needed.
  • timeout (of type float?, which defaults to 10.0): Timeout for network operations in seconds.
  • normalize_url (of type bool?, which defaults to null): Normalize url, replacing spaces with %20 and more. Defaults to settings.http.normalize_url when null.
  • (unlabeled) (of type string): Requested URL, e.g. "http://www.liquidsoap.info/".
  • on_body_data (of type (string?) -> unit): function called when receiving response body data. null or "" means that all the data has been passed.

Methods:

  • headers (of type [string * string]): HTTP headers.
  • http_version (of type string): Version of the HTTP protocol.
  • status_code (of type int): Status code.
  • status_message (of type string): Status message.

http.post

Perform a full http POST request.

Type:

(?data : {string}, ?headers : [string * string], ?http_version : string?,
?redirect : bool, ?timeout : float?, ?normalize_url : bool?, string) ->
string

Arguments:

  • data (of type {string}, which defaults to ""): POST data. Use a string getter to stream data and return "" when all data has been passed.
  • headers (of type [string * string], which defaults to []): Additional headers.
  • http_version (of type string?, which defaults to null): Http request version.
  • redirect (of type bool, which defaults to true): Perform redirections if needed.
  • timeout (of type float?, which defaults to 10.0): Timeout for network operations in seconds.
  • normalize_url (of type bool?, which defaults to null): Normalize url, replacing spaces with %20 and more. Defaults to settings.http.normalize_url when null.
  • (unlabeled) (of type string): Requested URL, e.g. "http://www.liquidsoap.info/".

Methods:

  • headers (of type [string * string]): HTTP headers.
  • http_version (of type string): Version of the HTTP protocol.
  • status_code (of type int): Status code.
  • status_message (of type string): Status message.

http.post.stream

Perform a full http POST request.

Type:

(?data : {string}, ?headers : [string * string], ?http_version : string?,
?redirect : bool, ?timeout : float?, ?normalize_url : bool?, string,
on_body_data : ((string?) -> unit)) -> unit

Arguments:

  • data (of type {string}, which defaults to ""): POST data. Use a string getter to stream data and return "" when all data has been passed.
  • headers (of type [string * string], which defaults to []): Additional headers.
  • http_version (of type string?, which defaults to null): Http request version.
  • redirect (of type bool, which defaults to true): Perform redirections if needed.
  • timeout (of type float?, which defaults to 10.0): Timeout for network operations in seconds.
  • normalize_url (of type bool?, which defaults to null): Normalize url, replacing spaces with %20 and more. Defaults to settings.http.normalize_url when null.
  • (unlabeled) (of type string): Requested URL, e.g. "http://www.liquidsoap.info/".
  • on_body_data (of type (string?) -> unit): function called when receiving response body data. null or "" means that all the data has been passed.

Methods:

  • headers (of type [string * string]): HTTP headers.
  • http_version (of type string): Version of the HTTP protocol.
  • status_code (of type int): Status code.
  • status_message (of type string): Status message.

http.put

Perform a full http PUT request.

Type:

(?data : {string}, ?headers : [string * string], ?http_version : string?,
?redirect : bool, ?timeout : float?, ?normalize_url : bool?, string) ->
string

Arguments:

  • data (of type {string}, which defaults to ""): POST data. Use a string getter to stream data and return "" when all data has been passed.
  • headers (of type [string * string], which defaults to []): Additional headers.
  • http_version (of type string?, which defaults to null): Http request version.
  • redirect (of type bool, which defaults to true): Perform redirections if needed.
  • timeout (of type float?, which defaults to 10.0): Timeout for network operations in seconds.
  • normalize_url (of type bool?, which defaults to null): Normalize url, replacing spaces with %20 and more. Defaults to settings.http.normalize_url when null.
  • (unlabeled) (of type string): Requested URL, e.g. "http://www.liquidsoap.info/".

Methods:

  • headers (of type [string * string]): HTTP headers.
  • http_version (of type string): Version of the HTTP protocol.
  • status_code (of type int): Status code.
  • status_message (of type string): Status message.

http.put.stream

Perform a full http PUT request.

Type:

(?data : {string}, ?headers : [string * string], ?http_version : string?,
?redirect : bool, ?timeout : float?, ?normalize_url : bool?, string,
on_body_data : ((string?) -> unit)) -> unit

Arguments:

  • data (of type {string}, which defaults to ""): POST data. Use a string getter to stream data and return "" when all data has been passed.
  • headers (of type [string * string], which defaults to []): Additional headers.
  • http_version (of type string?, which defaults to null): Http request version.
  • redirect (of type bool, which defaults to true): Perform redirections if needed.
  • timeout (of type float?, which defaults to 10.0): Timeout for network operations in seconds.
  • normalize_url (of type bool?, which defaults to null): Normalize url, replacing spaces with %20 and more. Defaults to settings.http.normalize_url when null.
  • (unlabeled) (of type string): Requested URL, e.g. "http://www.liquidsoap.info/".
  • on_body_data (of type (string?) -> unit): function called when receiving response body data. null or "" means that all the data has been passed.

Methods:

  • headers (of type [string * string]): HTTP headers.
  • http_version (of type string): Version of the HTTP protocol.
  • status_code (of type int): Status code.
  • status_message (of type string): Status message.

http.transport.ssl

Https transport using libssl

Type:

(?read_timeout : float?, ?write_timeout : float?, ?password : string?,
?min_protocol : string?, ?max_protocol : string?, ?certificate : string?,
?key : string?) -> http_transport

Arguments:

  • read_timeout (of type float?, which defaults to null): Read timeout
  • write_timeout (of type float?, which defaults to null): Write timeout
  • password (of type string?, which defaults to null): SSL certificate password
  • min_protocol (of type string?, which defaults to null): Minimal accepted SSL protocol. One of, from least recent to most recent: "ssl.3", "tls.1", "tls.1.1", "tls.1.2" or "tls.1.3". The most recent available protocol between client and server is negotiated when initiating communication between minimal and maximal protocol version. All protocols up to "tls.1.2" and above are now deprecated so you might want to set this value to one of those two. Default to lowest support protocol if not set.
  • max_protocol (of type string?, which defaults to null): Maximal accepted SSL protocol. One of, from least recent to most recent: "ssl.3", "tls.1", "tls.1.1", "tls.1.2" or "tls.1.3". The most recent available protocol between client and server is negotiated when initiating communication between minimal and maximal protocol version. Defaults to highest protocol supported if not set.
  • certificate (of type string?, which defaults to null): Path to certificate file. Required in server mode, e.g. input.harbor, etc. If passed in client mode, certificate is added to the list of valid certificates.
  • key (of type string?, which defaults to null): Path to certificate private key. Required in server mode, e.g. input.harbor, etc., unless the certificate file also contains the private key.

Methods:

  • default_port (of type int): Transport default port
  • name (of type string): Transport name
  • protocol (of type string): Transport protocol

http.transport.tls

Https transport using libtls

Type:

(?read_timeout : float?, ?write_timeout : float?, ?certificate : string?,
?key : string?, ?client_certificate : string?, ?client_key : string?) ->
http_transport

Arguments:

  • read_timeout (of type float?, which defaults to null): Read timeout. Defaults to harbor's timeout if null.
  • write_timeout (of type float?, which defaults to null): Write timeout. Defaults to harbor's timeout if null.
  • certificate (of type string?, which defaults to null): Path to certificate file. Required in server mode, e.g. input.harbor, etc. If passed in client mode, certificate is added to the list of valid certificates.
  • key (of type string?, which defaults to null): Path to certificate private key. Required in server mode, e.g. input.harbor, etc., unless the certificate file also contains the private key. Unused in client mode.
  • client_certificate (of type string?, which defaults to null): Path to client certificate file. If passed in server mode, clients will be required to present a certificate from this file. If passed in client mode, the first certificate in this file will be presented to the server.
  • client_key (of type string?, which defaults to null): Path to client certificate private key. Required in client mode if a client certificate is passed. Unused in server mode.

Methods:

  • default_port (of type int): Transport default port
  • name (of type string): Transport name
  • protocol (of type string): Transport protocol

http.transport.unix

Http unencrypted transport

Type:

http_transport.{default_port : int, name : string, protocol : string}

http.user_agent

Default user-agent

Type:

string

socket.address.internet_address

Create a socket address for a internet address.

Type:

(internet_address.{is_ipv6 : bool, to_string : () -> string}, int) ->
socket_address

Arguments:

  • (unlabeled) (of type internet_address.{is_ipv6 : bool, to_string : () -> string}): Internet address.
  • (unlabeled) (of type int): port

Methods:

  • domain (of type socket_domain): Socket domain
  • internet_address (of type internet_address.{is_ipv6 : bool, to_string : () -> string}): Internet address
  • port (of type int): Port

socket.address.unix

Create a socket address for a unix file socket.

Type:

(string) -> socket_address

Arguments:

  • (unlabeled) (of type string): Unix socket path

Methods:

  • domain (of type socket_domain): Socket domain
  • path (of type string): Unix socket path

socket.domain.inet

Inet socket domain

Type:

socket_domain

socket.domain.inet6

Inet6 socket domain

Type:

socket_domain

socket.domain.unix

Unix socket domain

Type:

socket_domain

socket.internet_address

Return an internet address from its string representation.

Type:

(string) -> internet_address

Arguments:

  • (unlabeled) (of type string): Socket internet address.

Methods:

  • is_ipv6 (of type bool): Is the internet address a ipv6 address?
  • to_string (of type () -> string): String representation of the internet address

socket.internet_address.any

A special IPv4 address, for use only with socket.bind, representing all the Internet addresses that the host machine possesses.

Type:

internet_address.{is_ipv6 : bool, to_string : () -> string}

socket.internet_address.ipv6.any

A special IPv6 address, for use only with socket.bind, representing all the Internet addresses that the host machine possesses.

Type:

internet_address.{is_ipv6 : bool, to_string : () -> string}

socket.internet_address.ipv6.loopback

A special IPv6 address representing the host machine (::1).

Type:

internet_address.{is_ipv6 : bool, to_string : () -> string}

socket.internet_address.loopback

A special IPv4 address representing the host machine (127.0.0.1).

Type:

internet_address.{is_ipv6 : bool, to_string : () -> string}

socket.pair

Create a pair of sockets connected together.

Type:

(?domain : socket_domain, ?type : socket_type, ?protocol : int) -> socket

Arguments:

  • domain (of type socket_domain, which defaults to socket.domain.inet): Socket domain.
  • type (of type socket_type, which defaults to socket.type.stream): Socket type
  • protocol (of type int, which defaults to 0): Protocol type. 0 selects the default protocol for that kind of sockets.

Methods:

  • close (of type () -> unit): Close the socket.
  • closed (of type () -> bool): true if the socket is already closed.
  • non_blocking (of type (bool) -> unit): Set the non-blocking flag on the socket
  • read (of type ((?timeout : float?) -> string) .{wait : (?timeout : float?, (() -> unit)) -> unit}): Read data from a socket. Reading is done when the function returns an empty string "".
  • type (of type string): Socket type
  • write (of type ((?timeout : float?, string) -> unit) .{wait : (?timeout : float?, (() -> unit)) -> unit}): Write data to a socket

socket.type.dgram

Dgram socket type

Type:

socket_type

socket.type.raw

Raw socket type

Type:

socket_type

socket.type.stream

Stream socket type

Type:

socket_type

socket.unix

Create a unix socket.

Type:

(?domain : socket_domain, ?type : socket_type, ?protocol : int) -> socket

Arguments:

  • domain (of type socket_domain, which defaults to socket.domain.inet): Socket domain.
  • type (of type socket_type, which defaults to socket.type.stream): Socket type
  • protocol (of type int, which defaults to 0): Protocol type. 0 selects the default protocol for that kind of sockets.

Methods:

  • accept (of type (?timeout : float?) -> socket .{ close : () -> unit, closed : () -> bool, non_blocking : (bool) -> unit, read : ((?timeout : float?) -> string) .{wait : (?timeout : float?, (() -> unit)) -> unit }, type : string, write : ((?timeout : float?, string) -> unit) .{wait : (?timeout : float?, (() -> unit)) -> unit } } * socket_address): Accept connections on the given socket. The returned socket is a socket connected to the client; the returned address is the address of the connecting client. Timeout defaults to harbor's accept_timeout if null.
  • bind (of type (socket_address) -> unit): Bind a socket to an address.
  • close (of type () -> unit): Close the socket.
  • closed (of type () -> bool): true if the socket is already closed.
  • connect (of type (socket_address) -> unit): Connect a socket to an address.
  • listen (of type (int) -> unit): Set up a socket for receiving connection requests. The integer argument is the maximal number of pending requests.
  • non_blocking (of type (bool) -> unit): Set the non-blocking flag on the socket
  • read (of type ((?timeout : float?) -> string) .{wait : (?timeout : float?, (() -> unit)) -> unit}): Read data from a socket. Reading is done when the function returns an empty string "".
  • type (of type string): Socket type
  • write (of type ((?timeout : float?, string) -> unit) .{wait : (?timeout : float?, (() -> unit)) -> unit}): Write data to a socket