aboutsummaryrefslogtreecommitdiff
path: root/src/rest.erl
diff options
context:
space:
mode:
authorPaweł Chmielowski <pchmielowski@process-one.net>2018-04-23 12:29:50 +0200
committerPaweł Chmielowski <pchmielowski@process-one.net>2018-04-23 12:29:56 +0200
commit9ed035776029f9c0d32fe2d81a3b59c58d9867a9 (patch)
tree443a382538c830e3e449e8cce887916b3c3dc1ba /src/rest.erl
parentAdd stubs for affiliation-specific backend callbacks (diff)
Use correct headers in rest calls
Diffstat (limited to 'src/rest.erl')
-rw-r--r--src/rest.erl22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/rest.erl b/src/rest.erl
index 18bf1b5ee..99501ae56 100644
--- a/src/rest.erl
+++ b/src/rest.erl
@@ -58,32 +58,32 @@ with_retry(Method, Args, Retries, MaxRetries, Backoff) ->
end.
get(Server, Path) ->
- request(Server, get, Path, [], "application/json", <<>>).
+ request(Server, get, Path, [], <<"application/json">>, <<>>).
get(Server, Path, Params) ->
- request(Server, get, Path, Params, "application/json", <<>>).
+ request(Server, get, Path, Params, <<"application/json">>, <<>>).
delete(Server, Path) ->
- request(Server, delete, Path, [], "application/json", <<>>).
+ request(Server, delete, Path, [], <<"application/json">>, <<>>).
post(Server, Path, Params, Content) ->
Data = encode_json(Content),
- request(Server, post, Path, Params, "application/json", Data).
+ request(Server, post, Path, Params, <<"application/json">>, Data).
put(Server, Path, Params, Content) ->
Data = encode_json(Content),
- request(Server, put, Path, Params, "application/json", Data).
+ request(Server, put, Path, Params, <<"application/json">>, Data).
patch(Server, Path, Params, Content) ->
Data = encode_json(Content),
- request(Server, patch, Path, Params, "application/json", Data).
+ request(Server, patch, Path, Params, <<"application/json">>, Data).
request(Server, Method, Path, Params, Mime, Data) ->
URI = url(Server, Path, Params),
Opts = [{connect_timeout, ?CONNECT_TIMEOUT},
{timeout, ?HTTP_TIMEOUT}],
- Hdrs = [{"connection", "keep-alive"},
- {"content-type", Mime},
- {"User-Agent", "ejabberd"}],
+ Hdrs = [{<<"connection">>, <<"keep-alive">>},
+ {<<"content-type">>, Mime},
+ {<<"User-Agent">>, <<"ejabberd">>}],
Begin = os:timestamp(),
Result = case catch p1_http:request(Method, URI, Hdrs, Data, Opts) of
{ok, Code, _, <<>>} ->
@@ -174,13 +174,13 @@ base_url(Server, Path) ->
end.
url(Url, []) ->
- binary_to_list(Url);
+ Url;
url(Url, Params) ->
L = [<<"&", (iolist_to_binary(Key))/binary, "=",
(misc:url_encode(Value))/binary>>
|| {Key, Value} <- Params],
<<$&, Encoded/binary>> = iolist_to_binary(L),
- binary_to_list(<<Url/binary, $?, Encoded/binary>>).
+ <<Url/binary, $?, Encoded/binary>>.
url(Server, Path, Params) ->
case binary:split(base_url(Server, Path), <<"?">>) of
[Url] ->