View Source hackney_url (hackney v1.23.0)

module to manage URLs.

Summary

Functions

Construct an URL from a base URL, a path and a list of properties to give to the URL.
Normalizes the encoding of an URL. Use the hackney_url:pathencode/1 to encode an URL.
Normalizes the encoding of an URL.
Parse an URL and return a #hackney_url record.

Equivalent to pathencode(Bin, []).

Encode query properties to binary.
Encode query properties to binary. Opts are passed to urlencode/2
Decode an URL encoded binary. The second argument specifies how to handle percent characters that are not followed by two valid hex characters. Use skip to ignore such errors, if crash is used the function will fail with the reason badarg.
URL encode a string binary.
URL encode a string binary. The noplus option disables the default behaviour of quoting space characters, \s, as +. The lower option overrides the default behaviour of writing hex numbers using uppercase letters to using lowercase letters instead.

Types

hackney_url/0

-type hackney_url() ::
          #hackney_url{transport :: atom(),
                       scheme :: atom(),
                       netloc :: binary(),
                       raw_path :: binary() | undefined,
                       path :: binary() | undefined | nil,
                       qs :: binary(),
                       fragment :: binary(),
                       host :: string(),
                       port :: integer() | undefined,
                       user :: binary(),
                       password :: binary()}.

qs_opt/0

-type qs_opt() :: noplus | upper.

qs_vals/0

-type qs_vals() :: [{binary() | atom() | list() | integer(), binary() | true}].

Functions

fix_path(Path)

idnconvert_hostname(Host)

make_url(Url, Path, Query)

-spec make_url(binary(), binary() | [binary()], binary() | qs_vals()) -> binary().
Construct an URL from a base URL, a path and a list of properties to give to the URL.

normalize(URL)

-spec normalize(URL) -> NormalizedUrl
                   when URL :: binary() | list() | hackney_url(), NormalizedUrl :: hackney_url().
Normalizes the encoding of an URL. Use the hackney_url:pathencode/1 to encode an URL.

normalize(URL, Fun)

-spec normalize(URL, Fun) -> NormalizedUrl
                   when
                       URL :: binary() | list() | hackney_url(),
                       Fun :: fun(),
                       NormalizedUrl :: hackney_url().
Normalizes the encoding of an URL.

parse_qs(Bin)

-spec parse_qs(binary()) -> qs_vals().

parse_url(URL)

-spec parse_url(URL :: binary() | list()) -> hackney_url().
Parse an URL and return a #hackney_url record.

pathencode(Path)

-spec pathencode(binary() | list()) -> binary().

Equivalent to pathencode(Bin, []).

Encode an URL path.

property(_, URL)

qs(KVs)

-spec qs(qs_vals()) -> binary().
Encode query properties to binary.

qs(KVs, Opts)

-spec qs(qs_vals(), [qs_opt()]) -> binary().
Encode query properties to binary. Opts are passed to urlencode/2

transport_scheme(_)

unparse_url(Hackney_url)

urldecode(Bin)

-spec urldecode(binary()) -> binary().

Equivalent to urldecode(Bin, crash).

Decode an URL encoded binary.

urldecode(Bin, OnError)

-spec urldecode(binary(), crash | skip) -> binary().
Decode an URL encoded binary. The second argument specifies how to handle percent characters that are not followed by two valid hex characters. Use skip to ignore such errors, if crash is used the function will fail with the reason badarg.

urlencode(Bin)

-spec urlencode(binary() | string()) -> binary().
URL encode a string binary.

urlencode(Bin, Opts)

-spec urlencode(binary() | string(), [qs_opt()]) -> binary().
URL encode a string binary. The noplus option disables the default behaviour of quoting space characters, \s, as +. The lower option overrides the default behaviour of writing hex numbers using uppercase letters to using lowercase letters instead.