diff options
author | Magnus Ahltorp <map@kth.se> | 2017-07-28 13:38:43 +0200 |
---|---|---|
committer | Magnus Ahltorp <map@kth.se> | 2017-07-28 13:38:43 +0200 |
commit | 11e0bdd000dad72ed4c46d419e253ee0caefbc2b (patch) | |
tree | 3c886c080433ce70bd23d682c730d232f2e87a3b /src | |
parent | 489df8ecaf16ca7429eb15b31ffbe6f686f5b0d1 (diff) |
Still WIPmergefetch
Diffstat (limited to 'src')
-rw-r--r-- | src/plop.erl | 8 | ||||
-rw-r--r-- | src/plop_httputil.erl | 21 |
2 files changed, 22 insertions, 7 deletions
diff --git a/src/plop.erl b/src/plop.erl index 7c7ded7..770c494 100644 --- a/src/plop.erl +++ b/src/plop.erl @@ -29,7 +29,7 @@ consistency/2, inclusion/2, inclusion_and_entry/2]). -export([generate_timestamp/0, save_sth/1, verify_sth/4]). -export([get_by_leaf_hash/1, entry_for_leafhash/1, spt_data_from_entry/1, - get_spt_sig/1, add_spt_sig/2]). + get_spt_sig/1, add_spt_sig/2, verify_entry/1]). %% API for tests. -export([testing_get_pubkey/0]). @@ -360,6 +360,12 @@ entry_for_leafhash(LeafHash) -> unwrap_entry(Entry) end. +verify_entry(Entry) -> + UnwrappedEntry = unwrap_entry(Entry), + {ok, {Module, Function}} = application:get_env(plop, verify_entry), + Module:Function(UnwrappedEntry). + + fill_in_entry({_Index, LeafHash, notfetched}) -> get_by_leaf_hash(LeafHash). diff --git a/src/plop_httputil.erl b/src/plop_httputil.erl index 81a99b1..b6bbf8e 100644 --- a/src/plop_httputil.erl +++ b/src/plop_httputil.erl @@ -92,7 +92,7 @@ request(DebugTag, URL, Headers, RequestBody, Method) -> get -> "GET"; post -> "POST" end, - #hackney_url{path = Path, host = Host} = ParsedURL, + #hackney_url{path = Path, host = Host, qs = QueryString, raw_path = RawPath} = ParsedURL, lager:debug("~s: sending http request to ~p", [DebugTag, URL]), case hackney:connect(ParsedURL, @@ -105,11 +105,20 @@ request(DebugTag, URL, Headers, RequestBody, Method) -> lager:debug("~s: connected to ~p", [DebugTag, URL]), {ok, StatusCode, RespHeaders, ClientRef} = - hackney:send_request(ConnRef, - {Method, Path, - add_auth(MethodString, Path, Headers, - RequestBody), - {fun chunk_data/1, RequestBody}}), + case Method of + post -> + hackney:send_request(ConnRef, + {Method, Path, + add_auth(MethodString, Path, Headers, + RequestBody), + {fun chunk_data/1, RequestBody}}); + get -> + hackney:send_request(ConnRef, + {Method, RawPath, + add_auth(MethodString, Path, Headers, + QueryString), + <<>>}) + end, lager:debug("~s: received headers for ~p: ~p", [DebugTag, URL, RespHeaders]), {ok, Body} = hackney:body(ClientRef), |