summaryrefslogtreecommitdiff
path: root/src/plop_httputil.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/plop_httputil.erl')
-rw-r--r--src/plop_httputil.erl13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/plop_httputil.erl b/src/plop_httputil.erl
index b4188e7..e428297 100644
--- a/src/plop_httputil.erl
+++ b/src/plop_httputil.erl
@@ -68,11 +68,20 @@ read_and_verify_cacertfile(Filename) ->
CorrectHash = CalculatedHash,
Der.
+request(DebugTag, URL, Headers, <<>>) ->
+ request(DebugTag, URL, Headers, <<>>, get);
request(DebugTag, URL, Headers, RequestBody) ->
+ request(DebugTag, URL, Headers, RequestBody, post).
+
+request(DebugTag, URL, Headers, RequestBody, Method) ->
Starttime = os:timestamp(),
ParsedURL = hackney_url:parse_url(URL),
CACertFile = application:get_env(plop, https_cacertfile, none),
CACert = read_and_verify_cacertfile(CACertFile),
+ MethodString = case Method of
+ get -> "GET";
+ post -> "POST"
+ end,
#hackney_url{path = Path, host = Host} = ParsedURL,
lager:debug("~s: sending http request to ~p",
[DebugTag, URL]),
@@ -87,8 +96,8 @@ request(DebugTag, URL, Headers, RequestBody) ->
[DebugTag, URL]),
{ok, StatusCode, RespHeaders, ClientRef} =
hackney:send_request(ConnRef,
- {post, Path,
- add_auth("POST", Path, Headers,
+ {Method, Path,
+ add_auth(MethodString, Path, Headers,
RequestBody),
RequestBody}),
lager:debug("~s: received headers for ~p: ~p",