Sippet v0.5.4 Sippet.Message.StatusLine

A SIP Status-Line struct, composed by the SIP-Version, Status-Code and the Reason-Phrase.

The start_line of responses are represented by this struct. The RFC 3261 represents the Status-Line as:

Status-Line  =  SIP-Version SP Status-Code SP Reason-Phrase CRLF

The above SIP-Version is represented by a {major, minor} tuple, which assumes the value {2, 0} in standard implementations.

The Status-Code is a 3-digit integer in the interval 100-699 indicating the outcome of an attempt to understand and satisfy a request.

The Reason-Phrase is a binary representing a short textual description of the Status-Code.

The Status-Code is intended for use by automata, whereas the Reason-Phrase is intended for the human user.

Summary

Functions

Returns a binary representing the default reason phrase for the given status_code

Returns a binary representing the default reason phrase for the given status_code

Returns a Status-Line struct

Creates a Status-Line struct using a given reason phrase

Returns an integer representing the status code class in the range [1, 6]

Returns an iodata which corresponds to the text representation of the given Status-Line

Returns a binary which corresponds to the text representation of the given Status-Line

Types

status_code()
status_code() :: 100..699
t()
t() :: %Sippet.Message.StatusLine{reason_phrase: binary, status_code: status_code, version: version}
version()
version() :: {integer, integer}

Functions

default_reason(status_code)
default_reason(status_code) :: binary | nil

Returns a binary representing the default reason phrase for the given status_code.

If the status_code does not have a corresponding default reason phrase, returns nil.

Examples

iex> Sippet.Message.StatusLine.default_reason(202)
"Accepted"
iex> Sippet.Message.StatusLine.default_reason(499)
nil
default_reason!(status_code)
default_reason!(status_code) :: binary | no_return

Returns a binary representing the default reason phrase for the given status_code.

If the status_code does not have a corresponding default reason phrase, throws an exception.

Examples

iex> Sippet.Message.StatusLine.default_reason!(202)
"Accepted"
iex> Sippet.Message.StatusLine.default_reason!(499)
** (ArgumentError) status code 499 does not have a default reason phrase
new(status_code)
new(status_code) :: t | no_return

Returns a Status-Line struct.

The reason_phrase is obtained from default values.

The function will throw an exception if the status_code is not in the valid range 100..699 or if the status_code does not have a default reason phrase.

The version will assume the default value {2, 0}.

Examples

iex> Sippet.Message.StatusLine.new(400)
%Sippet.Message.StatusLine{reason_phrase: "Bad Request", status_code: 400,
 version: {2, 0}}
new(status_code, reason_phrase)
new(status_code, reason_phrase :: binary) :: t

Creates a Status-Line struct using a given reason phrase.

In this function, the reason_phrase can be anything the application wants.

The function will throw an exception if the status_code is not in the valid range 100..699.

The version will assume the default value {2, 0}.

Examples

iex> Sippet.Message.StatusLine.new(499, "Foobar")
%Sippet.Message.StatusLine{reason_phrase: "Foobar", status_code: 499,
 version: {2, 0}}
status_code_class(status_line)
status_code_class(t) :: 1..6

Returns an integer representing the status code class in the range [1, 6].

Examples

iex> alias Sippet.Message.StatusLine
iex> StatusLine.new(202) |> StatusLine.status_code_class()
2
to_iodata(status_line)
to_iodata(t) :: iodata

Returns an iodata which corresponds to the text representation of the given Status-Line.

It does not includes an ending line CRLF.

Examples

iex> alias Sippet.StatusLine iex> StatusLine.new(202) |> StatusLine.to_iodata [“SIP/“, “2”, “.”, “0”, “ “, “202”, “ “, “Accepted”]

to_string(value)
to_string(t) :: binary

Returns a binary which corresponds to the text representation of the given Status-Line.

It does not includes an ending line CRLF.

Examples

iex> alias Sippet.StatusLine iex> StatusLine.new(202) |> StatusLine.to_string “SIP/2.0 202 Accepted”