ankh v0.10.0 Ankh.HTTP

Ankh HTTP public API

Link to this section Summary

Types

HTTP body

HTTP Header

HTTP Header name

HTTP Header value

HTTP Headers

Link to this section Types

Specs

body() :: iodata()

HTTP body

Specs

complete() :: boolean()

Specs

header() :: {header_name(), header_value()}

HTTP Header

Link to this type

header_name()

Specs

header_name() :: String.t()

HTTP Header name

Link to this type

header_value()

Specs

header_value() :: String.t()

HTTP Header value

Specs

headers() :: [header()]

HTTP Headers

Specs

msg() ::
  {msg_type(), reference(), iodata(), complete()}
  | {:error, reference(), Ankh.HTTP2.Error.t(), complete()}

Specs

msg_type() :: :headers | :data | :push_promise

Link to this section Functions

Link to this function

accept(uri, transport, options \\ [])

Specs

accept(URI.t(), Ankh.Transport.t(), 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.

Link to this function

close(protocol)

Specs

close(Ankh.Protocol.t()) :: :ok | {:error, any()}

Closes the underlying connection

Link to this function

connect(uri, transport, options \\ [])

Specs

connect(URI.t(), Ankh.Transport.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 to the server and stream can be used to receive receive responses.

Link to this function

error(protocol)

Specs

error(Ankh.Protocol.t()) :: :ok | {:error, any()}

Reports a connection error

Link to this function

fetch_header_values(map, name)

Specs

fetch_header_values(
  Ankh.HTTP.Request.t() | Ankh.HTTP.Response.t(),
  header_name()
) :: [header_value()]
Link to this function

fetch_trailer_values(map, name)

Specs

fetch_trailer_values(
  Ankh.HTTP.Request.t() | Ankh.HTTP.Response.t(),
  header_name()
) :: [header_value()]
Link to this function

put_header(response, name, value)

Specs

Link to this function

put_headers(response, headers)

Specs

Link to this function

put_trailer(response, name, value)

Specs

Link to this function

put_trailers(response, trailers)

Specs

Link to this function

request(protocol, request)

Specs

Sends a request to a server

Needs a connection to be established via connect beforehand.

Link to this function

respond(protocol, reference, response)

Specs

Sends a response to a client request

Needs a connection to be accepted via accept beforehand.

Link to this function

stream(protocol, msg)

Specs

stream(Ankh.Protocol.t(), any()) ::
  {:ok, Ankh.Protocol.t(), any()} | {:error, any()}

Receives data form the the other and and returns responses

Link to this function

validate_body(request)

Specs