buoy_protocol (buoy v0.2.6)

View Source

Summary

Types

bin_patterns/0

-type bin_patterns() :: #bin_patterns{rn :: binary:cp(), rnrn :: binary:cp()}.

body/0

-type body() :: undefined | iodata().

buoy_resp/0

-type buoy_resp() ::
          #buoy_resp{state :: body | done,
                     body :: undefined | binary(),
                     content_length :: undefined | non_neg_integer() | chunked,
                     headers :: undefined | [binary()],
                     reason :: undefined | binary(),
                     status_code :: undefined | 100..505}.

buoy_url/0

-type buoy_url() ::
          #buoy_url{host :: host(),
                    hostname :: hostname(),
                    path :: path(),
                    port :: inet:port_number(),
                    protocol :: protocol_http()}.

error/0

-type error() :: {error, term()}.

headers/0

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

host/0

-type host() :: binary().

hostname/0

-type hostname() :: binary().

method/0

-type method() :: get | head | post | put | {custom, binary()}.

path/0

-type path() :: binary().

protocol_http/0

-type protocol_http() :: http | https.

Functions

bin_patterns()

-spec bin_patterns() -> bin_patterns().

headers(Buoy_resp)

-spec headers(buoy_resp()) -> {ok, headers()} | {error, invalid_headers}.

request(Method, Path, Headers, Host, Body)

-spec request(method(), path(), headers(), host(), body()) -> iolist().

response(Data)

-spec response(binary()) -> {ok, buoy_resp(), binary()} | error().

response(Data, Method, Buoy_resp, BinPatterns)

-spec response(binary(), method(), undefined | buoy_resp(), bin_patterns()) ->
                  {ok, buoy_resp(), binary()} | error().