Accept binaries in URI parsing

Fixes #76
This commit is contained in:
Arnaud Cogoluègnes 2017-03-08 10:59:22 +01:00
parent 1546bb6a39
commit d396d59779
2 changed files with 5 additions and 3 deletions

View File

@ -70,8 +70,9 @@ parse(Uri, DefaultVHost) ->
error:Err -> {error, {Err, Uri}}
end.
parse1(Uri, DefaultVHost) when is_list(Uri) ->
case uri_parser:parse(Uri, [{host, undefined}, {path, undefined},
parse1(Uri, DefaultVHost) when is_list(Uri); is_binary(Uri) ->
UriString = rabbit_data_coercion:to_list(Uri),
case uri_parser:parse(UriString, [{host, undefined}, {path, undefined},
{port, undefined}, {'query', []}]) of
{error, Err} ->
throw({unable_to_parse_uri, Err});

View File

@ -40,7 +40,8 @@
%% 'fragment'.
parse(AbsURI, Defaults) ->
case parse_scheme(AbsURI) of
AbsUriString = rabbit_data_coercion:to_list(AbsURI),
case parse_scheme(AbsUriString) of
{error, Reason} ->
{error, Reason};
{Scheme, Rest} ->