View Source locus_http_download (locus v2.3.11)
Downloads a file using HTTP(S) without blocking the caller
Summary
Types
-type body() :: binary().
-type event() :: event_request_sent() | event_download_dismissed() | event_download_redirected() | event_download_failed_to_start() | event_download_started() | event_download_finished().
-type event_download_dismissed() :: {download_dismissed, full_http_response()}.
-type event_download_failed_to_start() :: {download_failed_to_start, reason_for_download_failing_to_start()}.
-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}}.
-type event_download_redirected() :: {download_redirected, redirection()}.
-type event_download_started() :: {download_started, headers()}.
-type full_http_response() :: {http, response_status(), headers(), body()}.
-type reason_for_download_failing_to_start() :: full_http_response() | too_many_redirections | {invalid_redirection, term()} | {error, term()} | timeout.
-type redirection() :: #{url := url(), permanence := permanent | temporary}.
-type response_status() :: {100..999, binary()}.
-opaque state()
-type url() :: string().