View Source aws_credentials_httpc (aws_credentials v0.3.3)

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

-type body() :: binary().
-type header() :: {string(), string()}.
-type headers() :: [header()].
-type http_version() :: string().
-type httpc_result() :: {status_line(), [header()], body()}.
-type method() :: atom().
-type reason_phrase() :: string().
-type response() :: {error, response_error()} | {ok, status_code(), body(), headers()}.
-type response_error() :: any().
-type status_code() :: non_neg_integer().
-type status_line() :: {http_version(), status_code(), reason_phrase()}.
-type url() :: string().

Functions

-spec request(method(), url()) -> response().
Attempt to request a URL with the 3 retries. 3 is the default.
Link to this function

request(Method, URL, RequestHeaders)

View Source
-spec request(method(), url(), [header()]) -> response().
Link to this function

request(Method, URL, RequestHeaders, Tries)

View Source
-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.
-spec start() -> ok.