aws_credentials_httpc (aws_credentials v1.0.3)

View Source

This implements an http client using the Erlang built in http client. If desired, this could be abstracted to support arbitrary http clients that return {ok, Status :: non_neg_integer(), Body :: binary(), Headers :: map()} or {error, Reasons :: [term()]}.

On errors, there will be a number of attempts with a delay equal to 100 milliseconds times the number of tries minus tries left. (So the first delay would be 100 milliseconds. The second delay would be 200 milliseconds, and so on...)

Summary

Functions

Attempt to request a URL with the 3 retries. 3 is the default.

Attempt to request a URL with a specified positive number of retries. (Minimum of 1.)

Types

body/0

-type body() :: binary().

header/0

-type header() :: {string(), binary() | string()}.

headers/0

-type headers() :: [header()].

http_version/0

-type http_version() :: string().

httpc_result/0

-type httpc_result() :: {status_line(), [header()], body()}.

method/0

-type method() :: atom().

reason_phrase/0

-type reason_phrase() :: string().

response/0

-type response() :: {error, response_error()} | {ok, status_code(), body(), headers()}.

response_error/0

-type response_error() :: any().

status_code/0

-type status_code() :: non_neg_integer().

status_line/0

-type status_line() :: {http_version(), status_code(), reason_phrase()}.

url/0

-type url() :: string().

Functions

request(Method, URL)

-spec request(method(), url()) -> response().

Attempt to request a URL with the 3 retries. 3 is the default.

request(Method, URL, RequestHeaders)

-spec request(method(), url(), [header()]) -> response().

request(Method, URL, RequestHeaders, Tries)

-spec request(method(), url(), [header()], pos_integer()) -> response().

Attempt to request a URL with a specified positive number of retries. (Minimum of 1.)

Note this function may return {ok, Results} even if it was unable to successfully get the desired data. That is, it will return an ok tuple with a status code of 500 or 404 or some other HTTP error code and no data.

start()

-spec start() -> ok.