Allow binary url (#95)

This commit is contained in:
Andrey Fadeev 2019-04-22 18:16:35 +03:00 committed by GitHub
parent 90eca45089
commit 749a3ab309
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -46,7 +46,7 @@
-export_type([handler/1, ev_handler/0, options/0]).
-type role() :: client | server.
-type url() :: string(). %% http://erlang.org/doc/man/httpc.html#http-data-types
-type url() :: binary() | string().
-type path() :: '_' | iodata(). %% cowboy_router:route_match()
-type http_handler(Handler) :: {path(), Handler}.
-export_type([role/0, url/0, path/0, http_handler/1]).

View File

@ -5,7 +5,7 @@
-include_lib("kernel/include/inet.hrl").
-include_lib("hackney/include/hackney_lib.hrl").
-type url() :: binary() | nonempty_string().
-type url() :: woody:url().
-type parsed_url() :: #hackney_url{}.
-type resolve_result() :: {Old::parsed_url(), New::parsed_url()}.
@ -42,7 +42,7 @@ resolve_url(Url, WoodyState) ->
{ok, resolve_result()} |
{error, Reason :: atom()}.
resolve_url(Url, WoodyState, Opts) when is_list(Url) ->
resolve_url(list_to_binary(Url), WoodyState, Opts);
resolve_url(unicode:characters_to_binary(Url), WoodyState, Opts);
resolve_url(<<"https://", _Rest/binary>> = Url, WoodyState, Opts) ->
resolve_parsed_url(parse_url(Url), WoodyState, Opts);
resolve_url(<<"http://", _Rest/binary>> = Url, WoodyState, Opts) ->