Servo.Parser (Tom Servo v0.1.0) View Source

Example HTTP Request:

Link to this section Summary

Functions

Convert HTTP Request string to a Request struct

Converts HTTP header lines to a Map

Parses a param string of the form key1=value1&key2=value2 into a map with corresponding keys and values.

Link to this section Functions

Convert HTTP Request string to a Request struct

Returns: %Request{}

Link to this function

parse_headers(header_lines)

View Source

Converts HTTP header lines to a Map

Examples

iex> header_lines = ["Host: example.com", "User-Agent: ExampleBrowser/1.0"]
iex> Servo.Parser.parse_headers(header_lines)
%{ "Host" => "example.com", "User-Agent" => "ExampleBrowser/1.0" }
Link to this function

parse_params(arg1, params_string)

View Source

Parses a param string of the form key1=value1&key2=value2 into a map with corresponding keys and values.

Examples

iex> params_string = "name=C3PO&color=gold"
iex> Servo.Parser.parse_params("application/x-www-form-urlencoded", params_string)
%{ "name" => "C3PO", "color" => "gold" }
iex> Servo.Parser.parse_params("multipart/form-data", params_string)
%{}
iex> params_string = ~s({"name": "C3PO", "color": "gold"})
iex> Servo.Parser.parse_params("application/json", params_string)
%{ "name" => "C3PO", "color" => "gold" }