raxx v0.11.0 Raxx.Connection

Manipulate connection header on raxx messages

Summary

Functions

Read connection of the HTTP message

Test if a Connection is marked as reuseable

Keep alive the connection for more messages

Set the connection of a HTTP message

Functions

fetch(map)

Read connection of the HTTP message.

Examples

iex> %Raxx.Request{headers: [{"connection", "close"}]} |> Raxx.Connection.fetch
{:ok, "close"}

iex> %Raxx.Request{headers: []} |> Raxx.Connection.fetch
{:error, :field_value_not_specified}
is_persistant?(request)

Test if a Connection is marked as reuseable

This behaviour depends if the HTTP version is 1.0 or 1.1.

TODO add a version field to the request/response types.

Assumes 1.1

Examples

iex> %Raxx.Request{headers: [{"connection", "close"}]} |> Raxx.Connection.is_persistant?
false

iex> %Raxx.Request{headers: []} |> Raxx.Connection.is_persistant?
true
mark_persistant(request)

Keep alive the connection for more messages.

Examples

iex> %Raxx.Response{} |> Raxx.Connection.mark_persistant() |> Raxx.Connection.fetch()
{:ok, "keep-alive"}
set(map, value)

Set the connection of a HTTP message.