HTTPill v0.2.0 HTTPill.Request View Source
Represents an HTTP request and carries all the information needed to issue one.
To get a new request with correctly handled data, please give a check on the
new/5
function.
Link to this section Summary
Functions
Creates a brand new request, correctly handling url and other configs, making it ready to be issued
Link to this section Types
Link to this type
t()
View Source
t() :: %HTTPill.Request{body: term, headers: HTTPill.HeaderList.t, method: atom, options: list, params: term, url: binary}
Link to this section Functions
Link to this function
new(method, url, options, config, before_process, after_process)
View Source
new(atom, binary, Keyword.t, HTTPill.Config.t, function, function) :: t
Creates a brand new request, correctly handling url and other configs, making it ready to be issued.
Here is the list of arg you must give:
method
- HTTP method as an atom (:get
,:head
,:post
,:put
,:delete
, etc.)url
- target url as a binary string or char listoptions
- Keyword list of options, see the available options belowconfig
-HTTPill.Config
object with the configurationsbefore_process
- a function to customize the request before building itafter_process
- a function to customize the request after building it
Options:
:body
- request body- a binary, char list or an iolist
- a map, which will be converted to json
{:form, [{K, V}, ...]}
- send a form url encoded{:file, "/path/to/file"}
- send a file{:stream, enumerable}
- lazily send a stream of binaries/charlists
:headers
- HTTP headers as an orddict (e.g.,[{"Accept", "application/json"}]
):params
- an enumerable consisting of two-item tuples that will be appended to the url as query string parameters:timeout
- timeout to establish a connection, in milliseconds. Default is 8000:recv_timeout
- timeout used when receiving a connection. Default is 5000:stream_to
- a PID to stream the response to:async
- if given:once
, will only stream one message at a time, requires call tostream_next
:proxy
- a proxy to be used for the request; it can be a regular url or a{Host, Port}
tuple:proxy_auth
- proxy authentication{User, Password}
tuple:ssl
- SSL options supported by thessl
erlang module:follow_redirect
- a boolean that causes redirects to be followed:max_redirect
- an integer denoting the maximum number of redirects to follow
Timeouts can be an integer or :infinity