httpotion v3.1.3 HTTPotion View Source
The HTTP client for Elixir.
This module contains a basic general-purpose HTTP client.
Everything in this module is created with use HTTPotion.Base.
You can create your own customized client modules (see the README).
Link to this section Summary
Types
List of options to all request functions.
Result returned from request!/3, get!/2, post!/2, put!/2, etc.
Functions
A shortcut for request(:delete, url, options).
A shortcut for request!(:delete, url, options).
A shortcut for request(:get, url, options).
A shortcut for request!(:get, url, options).
A shortcut for request(:head, url, options).
A shortcut for request!(:head, url, options).
A shortcut for request(:options, url, options).
A shortcut for request!(:options, url, options).
A shortcut for request(:patch, url, options).
A shortcut for request!(:patch, url, options).
A shortcut for request(:post, url, options).
A shortcut for request!(:post, url, options).
A shortcut for request(:put, url, options).
A shortcut for request!(:put, url, options).
Sends an HTTP request.
Like request/3, but raises HTTPotion.HTTPError if failed.
Starts a linked worker process for use with the direct option.
Starts a worker process for use with the direct option.
Ensures that HTTPotion and its dependencies are started.
Stops a worker process started with spawn_worker_process/2 or spawn_link_worker_process/2.
Link to this section Types
http_opts()
View Source
http_opts() :: [
body: binary() | charlist(),
headers: [{atom() | String.Chars.t(), String.Chars.t()}],
query: %{optional(String.Chars.t()) => String.Chars.t()},
timeout: timeout(),
basic_auth: {List.Chars.t(), List.Chars.t()},
stream_to: pid() | port() | atom() | {atom(), node()},
direct: pid() | port() | atom() | {atom(), node()},
ibrowse: keyword(),
auto_sni: boolean(),
follow_redirects: boolean()
]
http_opts() :: [ body: binary() | charlist(), headers: [{atom() | String.Chars.t(), String.Chars.t()}], query: %{optional(String.Chars.t()) => String.Chars.t()}, timeout: timeout(), basic_auth: {List.Chars.t(), List.Chars.t()}, stream_to: pid() | port() | atom() | {atom(), node()}, direct: pid() | port() | atom() | {atom(), node()}, ibrowse: keyword(), auto_sni: boolean(), follow_redirects: boolean() ]
List of options to all request functions.
body- request bodyheaders- HTTP headers (e.g.["Accept": "application/json"])query- URL query string (e.g.%{page: 1})timeout- timeout in millisecondsbasic_auth- basic auth credentials (e.g.{"user", "password"})stream_to- if you want to make an async request, reference to the processdirect- if you want to use ibrowse's direct feature, reference to the worker spawned byspawn_worker_process/2orspawn_link_worker_process/2ibrowse- options for ibrowseauto_sni- if true and the URL is https, configures theserver_name_indicationibrowse/ssl option to be the host part of the requestedURLfollow_redirects- if true and a response is a redirect, re-requests withheader[:Location]
http_result()
View Source
http_result() ::
HTTPotion.Response.t()
| %HTTPotion.AsyncResponse{id: term()}
| %HTTPotion.ErrorResponse{message: term()}
http_result() :: HTTPotion.Response.t() | %HTTPotion.AsyncResponse{id: term()} | %HTTPotion.ErrorResponse{message: term()}
http_result_bang()
View Source
http_result_bang() ::
HTTPotion.Response.t() | %HTTPotion.AsyncResponse{id: term()}
http_result_bang() :: HTTPotion.Response.t() | %HTTPotion.AsyncResponse{id: term()}
Result returned from request!/3, get!/2, post!/2, put!/2, etc.
Link to this section Functions
delete(url, options \\ [])
View Source
delete(String.Chars.t(), http_opts()) :: http_result()
delete(String.Chars.t(), http_opts()) :: http_result()
A shortcut for request(:delete, url, options).
delete!(url, options \\ [])
View Source
delete!(String.Chars.t(), http_opts()) :: http_result_bang()
delete!(String.Chars.t(), http_opts()) :: http_result_bang()
A shortcut for request!(:delete, url, options).
get(url, options \\ [])
View Source
get(String.Chars.t(), http_opts()) :: http_result()
get(String.Chars.t(), http_opts()) :: http_result()
A shortcut for request(:get, url, options).
get!(url, options \\ [])
View Source
get!(String.Chars.t(), http_opts()) :: http_result_bang()
get!(String.Chars.t(), http_opts()) :: http_result_bang()
A shortcut for request!(:get, url, options).
handle_response(response) View Source
head(url, options \\ [])
View Source
head(String.Chars.t(), http_opts()) :: http_result()
head(String.Chars.t(), http_opts()) :: http_result()
A shortcut for request(:head, url, options).
head!(url, options \\ [])
View Source
head!(String.Chars.t(), http_opts()) :: http_result_bang()
head!(String.Chars.t(), http_opts()) :: http_result_bang()
A shortcut for request!(:head, url, options).
is_redirect(response) View Source
options(url, options \\ [])
View Source
options(String.Chars.t(), http_opts()) :: http_result()
options(String.Chars.t(), http_opts()) :: http_result()
A shortcut for request(:options, url, options).
options!(url, options \\ [])
View Source
options!(String.Chars.t(), http_opts()) :: http_result_bang()
options!(String.Chars.t(), http_opts()) :: http_result_bang()
A shortcut for request!(:options, url, options).
patch(url, options \\ [])
View Source
patch(String.Chars.t(), http_opts()) :: http_result()
patch(String.Chars.t(), http_opts()) :: http_result()
A shortcut for request(:patch, url, options).
patch!(url, options \\ [])
View Source
patch!(String.Chars.t(), http_opts()) :: http_result_bang()
patch!(String.Chars.t(), http_opts()) :: http_result_bang()
A shortcut for request!(:patch, url, options).
post(url, options \\ [])
View Source
post(String.Chars.t(), http_opts()) :: http_result()
post(String.Chars.t(), http_opts()) :: http_result()
A shortcut for request(:post, url, options).
post!(url, options \\ [])
View Source
post!(String.Chars.t(), http_opts()) :: http_result_bang()
post!(String.Chars.t(), http_opts()) :: http_result_bang()
A shortcut for request!(:post, url, options).
process_options(options) View Source
process_request_body(body) View Source
process_request_headers(headers) View Source
process_request_headers(headers, body) View Source
process_request_headers(headers, body, options) View Source
process_response_body(body) View Source
process_response_body(headers, body) View Source
process_response_chunk(body) View Source
process_response_headers(headers) View Source
process_response_location(response) View Source
process_status_code(status_code) View Source
process_url(url) View Source
process_url(url, options) View Source
put(url, options \\ [])
View Source
put(String.Chars.t(), http_opts()) :: http_result()
put(String.Chars.t(), http_opts()) :: http_result()
A shortcut for request(:put, url, options).
put!(url, options \\ [])
View Source
put!(String.Chars.t(), http_opts()) :: http_result_bang()
put!(String.Chars.t(), http_opts()) :: http_result_bang()
A shortcut for request!(:put, url, options).
redirect_method(response, method) View Source
request(method, url, options \\ [])
View Source
request(atom(), String.Chars.t(), http_opts()) :: http_result()
request(atom(), String.Chars.t(), http_opts()) :: http_result()
Sends an HTTP request.
See the type documentation of http_opts for a description of options.
request(method, url, body, headers, options) View Source
request!(method, url, options \\ [])
View Source
request!(atom(), String.Chars.t(), http_opts()) :: http_result_bang()
request!(atom(), String.Chars.t(), http_opts()) :: http_result_bang()
Like request/3, but raises HTTPotion.HTTPError if failed.
request_direct(conn_pid, method, url, body \\ "", headers \\ [], options \\ []) View Source
response_ok(response) View Source
spawn_link_worker_process(url, options \\ []) View Source
Starts a linked worker process for use with the direct option.
spawn_worker_process(url, options \\ []) View Source
Starts a worker process for use with the direct option.
start() View Source
Ensures that HTTPotion and its dependencies are started.
stop_worker_process(pid) View Source
Stops a worker process started with spawn_worker_process/2 or spawn_link_worker_process/2.