aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Chmielowski <pawel@process-one.net>2021-12-06 15:07:59 +0100
committerPaweł Chmielowski <pawel@process-one.net>2021-12-06 15:08:10 +0100
commit7897c3d0e170495615d40152df9dbddb8df5d2df (patch)
tree472ca922806bbd0f8d4b592ef1c8dcef21678574
parentMerge pull request #3652 from weiss/bump-max-items (diff)
Add workaround for bug in older erlang version in rest module
-rw-r--r--src/rest.erl13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/rest.erl b/src/rest.erl
index d724352f2..038ec1fb1 100644
--- a/src/rest.erl
+++ b/src/rest.erl
@@ -197,7 +197,18 @@ url(Url, Params) ->
L = [<<"&", (iolist_to_binary(Key))/binary, "=",
(misc:url_encode(Value))/binary>>
|| {Key, Value} <- Params],
- <<$&, Encoded/binary>> = iolist_to_binary(L),
+ <<$&, Encoded0/binary>> = iolist_to_binary(L),
+ Encoded =
+ case erlang:function_exported(uri_string, normalize, 1) of
+ true ->
+ case uri_string:normalize("%25") of
+ "%" -> % This hack around bug in httpc >21 <23.2
+ binary:replace(Encoded0, <<"%25">>, <<"%2525">>, [global]);
+ _ -> Encoded0
+ end;
+ _ ->
+ Encoded0
+ end,
<<Url/binary, $?, Encoded/binary>>.
url(Server, Path, Params) ->
case binary:split(base_url(Server, Path), <<"?">>) of