View Source z_url_fetch (zotonic_stdlib v1.16.0)

Fetch (part of) the data of an Url, including its headers.

Link to this section Summary

Functions

Fetch the data and headers from an url
Fetch the data and headers from an url
Fetch the first kilobytes of data and headers from an url
Fetch the first N bytes of data and headers from an url, optionally save to the file device
Fetch the first N bytes of data and headers from an url, optionally save to the file device

Link to this section Types

-type fetch_result() ::
    {ok, {string(), [{string(), string()}], pos_integer(), binary()}} | {error, term()}.
-type option() ::
    {device, pid()} |
    {timeout, pos_integer()} |
    {max_length, pos_integer()} |
    {authorization, binary() | string()} |
    {accept, binary() | string()} |
    {user_agent, binary() | string()} |
    {language, atom()} |
    {content_type, binary() | string()} |
    insecure.
-type options() :: [option()].

Link to this section Functions

-spec ensure_profiles() -> ok.
-spec fetch(Url, Options) -> fetch_result() when Url :: string() | binary(), Options :: options().
Fetch the data and headers from an url
Link to this function

fetch(Method, Url, Payload, Options)

View Source
-spec fetch(Method, Url, Payload, Options) -> fetch_result()
         when
             Method :: get | post | put | delete | patch,
             Url :: string() | binary(),
             Payload :: binary(),
             Options :: options().
Fetch the data and headers from an url
-spec fetch_partial(Url) -> fetch_result() when Url :: string() | binary().
Fetch the first kilobytes of data and headers from an url
Link to this function

fetch_partial(Url, Options)

View Source
-spec fetch_partial(Url, Options) -> fetch_result()
                 when Url :: string() | binary(), Options :: options().
Fetch the first N bytes of data and headers from an url, optionally save to the file device
Link to this function

fetch_partial(Method, Url, Payload, Options)

View Source
-spec fetch_partial(Method, Url, Payload, Options) -> fetch_result()
                 when
                     Method :: get | post | delete | put | patch,
                     Url :: string() | binary(),
                     Payload :: binary(),
                     Options :: options().
Fetch the first N bytes of data and headers from an url, optionally save to the file device
-spec periodic_cleanup() -> ok.
-spec profile(string() | binary()) -> atom().