View Source locus_http_download (locus v2.3.7)

Downloads a file using HTTP(S) without blocking the caller

Link to this section Summary

Link to this section Types

Specs

body() :: binary().

Specs

Link to this type

event_download_dismissed/0

View Source

Specs

event_download_dismissed() :: {download_dismissed, full_http_response()}.
Link to this type

event_download_failed_to_start/0

View Source

Specs

event_download_failed_to_start() ::
    {download_failed_to_start, reason_for_download_failing_to_start()}.
Link to this type

event_download_finished/0

View Source

Specs

event_download_finished() ::
    {download_finished, BodySize :: non_neg_integer(), {ok, TrailingHeaders :: headers()}} |
    {download_finished, BodySize :: non_neg_integer(), {error, term()}} |
    {download_finished, BodySize :: non_neg_integer(), {error, timeout}}.
Link to this type

event_download_redirected/0

View Source

Specs

event_download_redirected() :: {download_redirected, redirection()}.
Link to this type

event_download_started/0

View Source

Specs

event_download_started() :: {download_started, headers()}.

Specs

event_request_sent() :: {request_sent, url(), headers()}.

Specs

full_http_response() :: {http, response_status(), headers(), body()}.

Specs

headers() :: [{string(), string()}].

Specs

msg() ::
    {event, event()} |
    {finished, {success, success()}} |
    {finished, dismissed} |
    {finished, {error, term()}}.

Specs

opt() ::
    {connect_timeout, timeout()} |
    {download_start_timeout, timeout()} |
    {idle_download_timeout, timeout()} |
    insecure |
    {insecure, boolean()} |
    {censor_query, CensoredKeys :: [atom()]}.
Link to this type

reason_for_download_failing_to_start/0

View Source

Specs

reason_for_download_failing_to_start() ::
    full_http_response() |
    too_many_redirections |
    {invalid_redirection, term()} |
    {error, term()} |
    timeout.

Specs

redirection() :: #{url := url(), permanence := permanent | temporary}.

Specs

response_status() :: {100..999, binary()}.

Specs

state() :: #state{}.

Specs

success() :: #{headers := headers(), body := binary()}.

Specs

url() :: string().

Link to this section Functions

Link to this function

code_change(OldVsn, State, Extra)

View Source

Specs

code_change(term(), state(), term()) -> {ok, state()}.
Link to this function

handle_call(Call, From, State)

View Source

Specs

handle_call(term(), {pid(), reference()}, state()) -> {stop, unexpected_call, state()}.
Link to this function

handle_cast(Cast, State)

View Source

Specs

handle_cast(term(), state()) -> {stop, unexpected_cast, state()}.
Link to this function

handle_info(Info, State)

View Source

Specs

handle_info(term(), state()) ->
               {noreply, state()} | {stop, normal, state()} | {stop, unexpected_info, state()}.

Specs

init([InitArg, ...]) -> {ok, state()}
        when
            InitArg :: OwnerPid | URL | Headers | Opts,
            OwnerPid :: pid(),
            URL :: url(),
            Headers :: headers(),
            Opts :: [opt()].
Link to this function

start_link(URL, Headers, Opts)

View Source

Specs

start_link(url(), headers(), [opt()]) -> {ok, pid()}.
Link to this function

terminate(Reason, State)

View Source

Specs

terminate(term(), state()) -> ok.
Link to this function

validate_opts(MixedOpts)

View Source

Specs

validate_opts(proplists:proplist()) ->
                 {ok, {[opt()], proplists:proplist()}} | {error, BadOpt :: term()}.