View Source HTTPSpec.Request (http_spec v1.1.0)
A struct for describing HTTP request.
Summary
Functions
Deletes the header given by name
.
Returns the values of the header specified by name
.
Puts a request header name
to value
.
Puts a request header name
to value
unless already present.
Types
Functions
@spec build(keyword() | map()) :: {:ok, t()} | {:error, HTTPSpec.ArgumentError.t()}
Deletes the header given by name
.
All occurrences of the header are deleted, in case the header is repeated multiple times.
Examples
iex> Request.get_header(request, "cache-control")
["max-age=600", "no-transform"]
iex> request = Request.delete_header(req, "cache-control")
iex> Req.Request.get_header(request, "cache-control")
[]
Returns the values of the header specified by name
.
Examples
iex> Request.get_header(request, "accept")
["application/json"]
iex> Request.get_header(requset, "x-unknown")
[]
Puts a request header name
to value
.
If the header was previously set, its value is overwritten.
Examples
iex> Request.get_header(request, "accept")
[]
iex> request = Request.put_header(request, "accept", "application/json")
iex> Request.get_header(request, "accept")
["application/json"]
Puts a request header name
to value
unless already present.
See put_header/3
for more information.
Examples
iex> request =
...> request
...> |> Req.Request.put_new_header("accept", "application/json")
...> |> Req.Request.put_new_header("accept", "text/html")
iex> Req.Request.get_header(request, "accept")
["application/json"]