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 typeint, which defaults to8000): Port to serve.transport(of typehttp_transport.{default_port : int, name : string, protocol : string}, which defaults to<unix_transport>.{default_port=80, protocol="http", name="unix"}): Http transport. Usehttp.transport.sslorhttp.transport.secure_transport, when available, to enable HTTPS outputmethod(of typestring, which defaults to"GET"): Accepted method ("GET" / "POST" / "PUT" / "DELETE" / "HEAD" / "OPTIONS").(unlabeled)(of typeregexp): 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 typeint, which defaults to8000): Port to serve.method(of typestring, which defaults to"GET"): Method served.(unlabeled)(of typeregexp): 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 typeinternet_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 typestring): 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 typestring?, which defaults tonull): Http request version.redirect(of typebool, which defaults totrue): Perform redirections if needed.timeout(of typefloat?, which defaults to10.0): Timeout for network operations in seconds.normalize_url(of typebool?, which defaults tonull): Normalize url, replacing spaces with%20and more. Defaults tosettings.http.normalize_urlwhennull.(unlabeled)(of typestring): Requested URL, e.g."http://www.liquidsoap.info/".
Methods:
headers(of type[string * string]): HTTP headers.http_version(of typestring): Version of the HTTP protocol.status_code(of typeint): Status code.status_message(of typestring): 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 typestring?, which defaults tonull): Http request version.redirect(of typebool, which defaults totrue): Perform redirections if needed.timeout(of typefloat?, which defaults to10.0): Timeout for network operations in seconds.normalize_url(of typebool?, which defaults tonull): Normalize url, replacing spaces with%20and more. Defaults tosettings.http.normalize_urlwhennull.(unlabeled)(of typestring): Requested URL, e.g."http://www.liquidsoap.info/".on_body_data(of type(string?) -> unit): function called when receiving response body data.nullor""means that all the data has been passed.
Methods:
headers(of type[string * string]): HTTP headers.http_version(of typestring): Version of the HTTP protocol.status_code(of typeint): Status code.status_message(of typestring): 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 typestring?, which defaults tonull): Http request version.redirect(of typebool, which defaults totrue): Perform redirections if needed.timeout(of typefloat?, which defaults to10.0): Timeout for network operations in seconds.normalize_url(of typebool?, which defaults tonull): Normalize url, replacing spaces with%20and more. Defaults tosettings.http.normalize_urlwhennull.(unlabeled)(of typestring): Requested URL, e.g."http://www.liquidsoap.info/".
Methods:
headers(of type[string * string]): HTTP headers.http_version(of typestring): Version of the HTTP protocol.status_code(of typeint): Status code.status_message(of typestring): 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 typestring?, which defaults tonull): Http request version.redirect(of typebool, which defaults totrue): Perform redirections if needed.timeout(of typefloat?, which defaults to10.0): Timeout for network operations in seconds.normalize_url(of typebool?, which defaults tonull): Normalize url, replacing spaces with%20and more. Defaults tosettings.http.normalize_urlwhennull.(unlabeled)(of typestring): Requested URL, e.g."http://www.liquidsoap.info/".on_body_data(of type(string?) -> unit): function called when receiving response body data.nullor""means that all the data has been passed.
Methods:
headers(of type[string * string]): HTTP headers.http_version(of typestring): Version of the HTTP protocol.status_code(of typeint): Status code.status_message(of typestring): 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 typestring?, which defaults tonull): Http request version.redirect(of typebool, which defaults totrue): Perform redirections if needed.timeout(of typefloat?, which defaults to10.0): Timeout for network operations in seconds.normalize_url(of typebool?, which defaults tonull): Normalize url, replacing spaces with%20and more. Defaults tosettings.http.normalize_urlwhennull.(unlabeled)(of typestring): Requested URL, e.g."http://www.liquidsoap.info/".
Methods:
headers(of type[string * string]): HTTP headers.http_version(of typestring): Version of the HTTP protocol.status_code(of typeint): Status code.status_message(of typestring): 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 typestring?, which defaults tonull): Http request version.redirect(of typebool, which defaults totrue): Perform redirections if needed.timeout(of typefloat?, which defaults to10.0): Timeout for network operations in seconds.normalize_url(of typebool?, which defaults tonull): Normalize url, replacing spaces with%20and more. Defaults tosettings.http.normalize_urlwhennull.(unlabeled)(of typestring): Requested URL, e.g."http://www.liquidsoap.info/".on_body_data(of type(string?) -> unit): function called when receiving response body data.nullor""means that all the data has been passed.
Methods:
headers(of type[string * string]): HTTP headers.http_version(of typestring): Version of the HTTP protocol.status_code(of typeint): Status code.status_message(of typestring): 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 astringgetter to stream data and return""when all data has been passed.headers(of type[string * string], which defaults to[]): Additional headers.http_version(of typestring?, which defaults tonull): Http request version.redirect(of typebool, which defaults totrue): Perform redirections if needed.timeout(of typefloat?, which defaults to10.0): Timeout for network operations in seconds.normalize_url(of typebool?, which defaults tonull): Normalize url, replacing spaces with%20and more. Defaults tosettings.http.normalize_urlwhennull.(unlabeled)(of typestring): Requested URL, e.g."http://www.liquidsoap.info/".
Methods:
headers(of type[string * string]): HTTP headers.http_version(of typestring): Version of the HTTP protocol.status_code(of typeint): Status code.status_message(of typestring): 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 astringgetter to stream data and return""when all data has been passed.headers(of type[string * string], which defaults to[]): Additional headers.http_version(of typestring?, which defaults tonull): Http request version.redirect(of typebool, which defaults totrue): Perform redirections if needed.timeout(of typefloat?, which defaults to10.0): Timeout for network operations in seconds.normalize_url(of typebool?, which defaults tonull): Normalize url, replacing spaces with%20and more. Defaults tosettings.http.normalize_urlwhennull.(unlabeled)(of typestring): Requested URL, e.g."http://www.liquidsoap.info/".on_body_data(of type(string?) -> unit): function called when receiving response body data.nullor""means that all the data has been passed.
Methods:
headers(of type[string * string]): HTTP headers.http_version(of typestring): Version of the HTTP protocol.status_code(of typeint): Status code.status_message(of typestring): 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 astringgetter to stream data and return""when all data has been passed.headers(of type[string * string], which defaults to[]): Additional headers.http_version(of typestring?, which defaults tonull): Http request version.redirect(of typebool, which defaults totrue): Perform redirections if needed.timeout(of typefloat?, which defaults to10.0): Timeout for network operations in seconds.normalize_url(of typebool?, which defaults tonull): Normalize url, replacing spaces with%20and more. Defaults tosettings.http.normalize_urlwhennull.(unlabeled)(of typestring): Requested URL, e.g."http://www.liquidsoap.info/".
Methods:
headers(of type[string * string]): HTTP headers.http_version(of typestring): Version of the HTTP protocol.status_code(of typeint): Status code.status_message(of typestring): 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 astringgetter to stream data and return""when all data has been passed.headers(of type[string * string], which defaults to[]): Additional headers.http_version(of typestring?, which defaults tonull): Http request version.redirect(of typebool, which defaults totrue): Perform redirections if needed.timeout(of typefloat?, which defaults to10.0): Timeout for network operations in seconds.normalize_url(of typebool?, which defaults tonull): Normalize url, replacing spaces with%20and more. Defaults tosettings.http.normalize_urlwhennull.(unlabeled)(of typestring): Requested URL, e.g."http://www.liquidsoap.info/".on_body_data(of type(string?) -> unit): function called when receiving response body data.nullor""means that all the data has been passed.
Methods:
headers(of type[string * string]): HTTP headers.http_version(of typestring): Version of the HTTP protocol.status_code(of typeint): Status code.status_message(of typestring): 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 typefloat?, which defaults tonull): Read timeoutwrite_timeout(of typefloat?, which defaults tonull): Write timeoutpassword(of typestring?, which defaults tonull): SSL certificate passwordmin_protocol(of typestring?, which defaults tonull): 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 typestring?, which defaults tonull): 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 typestring?, which defaults tonull): 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 typestring?, which defaults tonull): 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 typeint): Transport default portname(of typestring): Transport nameprotocol(of typestring): 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 typefloat?, which defaults tonull): Read timeout. Defaults to harbor's timeout ifnull.write_timeout(of typefloat?, which defaults tonull): Write timeout. Defaults to harbor's timeout ifnull.certificate(of typestring?, which defaults tonull): 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 typestring?, which defaults tonull): 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 typestring?, which defaults tonull): 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 typestring?, which defaults tonull): Path to client certificate private key. Required in client mode if a client certificate is passed. Unused in server mode.
Methods:
default_port(of typeint): Transport default portname(of typestring): Transport nameprotocol(of typestring): 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 typeinternet_address.{is_ipv6 : bool, to_string : () -> string}): Internet address.(unlabeled)(of typeint): port
Methods:
domain(of typesocket_domain): Socket domaininternet_address(of typeinternet_address.{is_ipv6 : bool, to_string : () -> string}): Internet addressport(of typeint): Port
socket.address.unix
Create a socket address for a unix file socket.
Type:
(string) -> socket_address
Arguments:
(unlabeled)(of typestring): Unix socket path
Methods:
domain(of typesocket_domain): Socket domainpath(of typestring): 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 typestring): Socket internet address.
Methods:
is_ipv6(of typebool): 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 typesocket_domain, which defaults tosocket.domain.inet): Socket domain.type(of typesocket_type, which defaults tosocket.type.stream): Socket typeprotocol(of typeint, which defaults to0): Protocol type.0selects the default protocol for that kind of sockets.
Methods:
close(of type() -> unit): Close the socket.closed(of type() -> bool):trueif the socket is already closed.non_blocking(of type(bool) -> unit): Set the non-blocking flag on the socketread(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 typestring): Socket typewrite(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 typesocket_domain, which defaults tosocket.domain.inet): Socket domain.type(of typesocket_type, which defaults tosocket.type.stream): Socket typeprotocol(of typeint, which defaults to0): Protocol type.0selects 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 ifnull.bind(of type(socket_address) -> unit): Bind a socket to an address.close(of type() -> unit): Close the socket.closed(of type() -> bool):trueif 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 socketread(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 typestring): Socket typewrite(of type((?timeout : float?, string) -> unit) .{wait : (?timeout : float?, (() -> unit)) -> unit}): Write data to a socket