fix(emqx_coap_ps_resource): Copy uri decode code from OTP-22

This commit is contained in:
Zaiming Shi 2021-01-27 19:19:38 +01:00
parent f42e52e84e
commit d38b626579
1 changed files with 7 additions and 7 deletions

View File

@ -259,13 +259,13 @@ handle_received_create(TopicPrefix, MaxAge, Payload) ->
{error, bad_request} {error, bad_request}
end. end.
%% http_uri:decode/1 is deprecated in OTP-23 %% @private Copy from http_uri.erl which has been deprecated since OTP-23
%% its equivalent uri_string:percent_decode however is not available before OTP 23 percent_decode(<<$%, Hex:2/binary, Rest/bits>>) ->
-if(?OTP_RELEASE >= 23). <<(binary_to_integer(Hex, 16)), (percent_decode(Rest))/binary>>;
percent_decode(Topic) -> uri_string:percent_decode(Topic). percent_decode(<<First:1/binary, Rest/bits>>) ->
-else. <<First/binary, (percent_decode(Rest))/binary>>;
percent_decode(Topic) -> http_uri:decode(Topic). percent_decode(<<>>) ->
-endif. <<>>.
%% When topic is timeout, server should return nocontent here, %% When topic is timeout, server should return nocontent here,
%% but gen_coap only receive return value of #coap_content from coap_get, so temporarily we can't give the Code 2.07 {ok, nocontent} out.TBC!!! %% but gen_coap only receive return value of #coap_content from coap_get, so temporarily we can't give the Code 2.07 {ok, nocontent} out.TBC!!!