locus_http_download (locus v2.3.14)

View Source

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

Summary

Types

body/0

-type body() :: binary().

event/0

event_download_dismissed/0

-type event_download_dismissed() :: {download_dismissed, full_http_response()}.

event_download_failed_to_start/0

-type event_download_failed_to_start() ::
          {download_failed_to_start, reason_for_download_failing_to_start()}.

event_download_finished/0

-type 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}}.

event_download_redirected/0

-type event_download_redirected() :: {download_redirected, redirection()}.

event_download_started/0

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

event_request_sent/0

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

full_http_response/0

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

headers/0

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

msg/0

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

opt/0

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

reason_for_download_failing_to_start/0

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

redirection/0

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

response_status/0

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

state/0

-opaque state()

success/0

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

url/0

-type url() :: string().