Ankh.HTTP (ankh v0.15.0)
HTTP public interface
This module implements Ankh
public APIs and provides protocol negotiation.
Link to this section Summary
Functions
Accepts an HTTP connection
Closes the underlying connection
Establishes an HTTP connection to a server
Reports a connection error
Sends a request to a server
Sends a response to a client request
Receives a transport message and returns responses
Receives data and returns responses
Link to this section Types
body()
Specs
body() :: iodata()
HTTP body
complete()
Specs
complete() :: boolean()
header()
Specs
header() :: {header_name(), header_value()}
HTTP Header
header_name()
Specs
header_name() :: String.t()
HTTP Header name
header_value()
Specs
header_value() :: String.t()
HTTP Header value
headers()
Specs
headers() :: [header()]
HTTP Headers
response()
Specs
Link to this section Functions
accept(uri, socket, options \\ [])
Specs
accept(URI.t(), Ankh.Transport.socket(), Ankh.Transport.options()) :: {:ok, Ankh.Protocol.t()} | {:error, any()}
Accepts an HTTP connection
After accepting the connection, stream
will receive requests from the client and respond
can be used to send replies.
close(protocol)
Specs
close(Ankh.Protocol.t()) :: :ok | {:error, any()}
Closes the underlying connection
connect(uri, options \\ [])
Specs
connect(URI.t(), Ankh.Transport.options()) :: {:ok, Ankh.Protocol.t()} | {:error, any()}
Establishes an HTTP connection to a server
After establishing the connection, request
can be user to send request
and stream
can be used to receive responses from the server.
error(protocol)
Specs
error(Ankh.Protocol.t()) :: :ok | {:error, any()}
Reports a connection error
header_name_valid?(name, strict)
Specs
header_name_valid?(header_name(), boolean()) :: boolean()
request(protocol, request)
Specs
request(Ankh.Protocol.t(), Ankh.HTTP.Request.t()) :: {:ok, Ankh.Protocol.t(), Ankh.Protocol.request_ref()} | {:error, any()}
Sends a request to a server
Needs a connection to be established via connect
beforehand.
respond(protocol, reference, response)
Specs
respond(Ankh.Protocol.t(), Ankh.Protocol.request_ref(), Ankh.HTTP.Response.t()) :: {:ok, Ankh.Protocol.t()} | {:error, any()}
Sends a response to a client request
Needs a connection to be accepted via accept
beforehand.
stream(protocol, msg)
Specs
stream(Ankh.Protocol.t(), Ankh.Transport.msg()) :: {:ok, Ankh.Protocol.t(), any()} | {:error, any()}
Receives a transport message and returns responses
stream_data(protocol, data)
Specs
stream_data(Ankh.Protocol.t(), Ankh.Transport.data()) :: {:ok, Ankh.Protocol.t(), any()} | {:error, any()}
Receives data and returns responses