Ewebmachine.Core.Utils (ewebmachine v2.3.0) View Source

HTTP utility module

Link to this section Summary

Functions

HTTP Charset negociation, get the charset to use from :

HTTP Encoding negociation, get the encoding to use from :

HTTP Content negociation, get the content type to send from :

Convert rfc1123 or rfc850 to :calendar dates

Format a norm_content_type into an HTTP content type header

Match normalized media types accepting a partial match (wildcard or incomplete params)

Get HTTP status label from HTTP code

Convert any content type representation (see spec) into a norm_content_type

Remove quotes from HTTP quoted string

Convert a calendar date to a rfc1123 date string

Get the string list from a comma separated list of HTTP quoted strings

Link to this section Types

Specs

norm_content_type() ::
  {type :: String.t(), subtype :: String.t(), params :: map()}

Link to this section Functions

Link to this function

choose_charset(charsets, acc_char_hdr)

View Source

Specs

choose_charset([String.t()], String.t()) :: String.t() | nil

HTTP Charset negociation, get the charset to use from :

  • acc_char_hdr, the HTTP header Accept-Charset
  • charsets, the list of supported charsets
Link to this function

choose_encoding(encs, acc_enc_hdr)

View Source

Specs

choose_encoding([String.t()], String.t()) :: String.t() | nil

HTTP Encoding negociation, get the encoding to use from :

  • acc_enc_hdr, the HTTP header Accept-Encoding
  • encs, the list of supported encoding
Link to this function

choose_media_type(ct_provided, accept_header)

View Source

Specs

choose_media_type([norm_content_type()], String.t()) ::
  norm_content_type() | nil

HTTP Content negociation, get the content type to send from :

  • accept_header, the HTTP header Accept
  • ct_provided, the list of provided content types
Link to this function

convert_request_date(date)

View Source

Specs

convert_request_date(String.t()) ::
  {{year :: integer(), month :: integer(), day :: integer()},
   {h :: integer(), min :: integer(), sec :: integer()}}
  | :bad_date

Convert rfc1123 or rfc850 to :calendar dates

Specs

format_mtype(norm_content_type()) :: String.t()

Format a norm_content_type into an HTTP content type header

Link to this function

fuzzy_mt_match(arg1, arg2)

View Source

Specs

fuzzy_mt_match(norm_content_type(), norm_content_type()) :: boolean()

Match normalized media types accepting a partial match (wildcard or incomplete params)

Specs

http_label(code :: integer()) :: String.t()

Get HTTP status label from HTTP code

Specs

normalize_mtype(
  {type :: String.t(), params :: map()}
  | (type :: String.t())
  | norm_content_type()
) :: norm_content_type()

Convert any content type representation (see spec) into a norm_content_type

Specs

quoted_string(String.t()) :: String.t()

Remove quotes from HTTP quoted string

Specs

rfc1123_date(
  {{year :: integer(), month :: integer(), day :: integer()},
   {h :: integer(), min :: integer(), sec :: integer()}}
) :: String.t()

Convert a calendar date to a rfc1123 date string

Link to this function

split_quoted_strings(str)

View Source

Specs

split_quoted_strings([String.t()]) :: [String.t()]

Get the string list from a comma separated list of HTTP quoted strings