summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plop_compat.erl6
-rw-r--r--src/plop_httputil.erl12
-rw-r--r--src/storage.erl2
3 files changed, 18 insertions, 2 deletions
diff --git a/src/plop_compat.erl b/src/plop_compat.erl
index 4c212de..9a98e3d 100644
--- a/src/plop_compat.erl
+++ b/src/plop_compat.erl
@@ -22,6 +22,10 @@ unpack_spki("17", SPKI) ->
unpack_spki("18", SPKI) ->
#'SubjectPublicKeyInfo'{subjectPublicKey = Octets,
algorithm = Algorithm} = SPKI,
+ {Octets, Algorithm};
+unpack_spki("19", SPKI) ->
+ #'SubjectPublicKeyInfo'{subjectPublicKey = Octets,
+ algorithm = Algorithm} = SPKI,
{Octets, Algorithm}.
%% <=R17: now/0, >=R18 timestamp/0
@@ -30,4 +34,6 @@ timestamp("R16" ++ _) ->
timestamp("17") ->
erlang:now();
timestamp("18") ->
+ erlang:timestamp();
+timestamp("19") ->
erlang:timestamp().
diff --git a/src/plop_httputil.erl b/src/plop_httputil.erl
index 67e48ba..81a99b1 100644
--- a/src/plop_httputil.erl
+++ b/src/plop_httputil.erl
@@ -73,6 +73,16 @@ request(DebugTag, URL, Headers, <<>>) ->
request(DebugTag, URL, Headers, RequestBody) ->
request(DebugTag, URL, Headers, RequestBody, post).
+-define(MAX_CHUNK_SIZE, 512*1024).
+
+chunk_data(<<>>) ->
+ eof;
+chunk_data(Data) when is_binary(Data) ->
+ ChunkSize = min(size(Data), ?MAX_CHUNK_SIZE),
+ lager:debug("~p data left, sending ~p bytes", [size(Data), ChunkSize]),
+ {Chunk, Rest} = split_binary(Data, ChunkSize),
+ {ok, Chunk, Rest}.
+
request(DebugTag, URL, Headers, RequestBody, Method) ->
Starttime = os:timestamp(),
ParsedURL = hackney_url:parse_url(URL),
@@ -99,7 +109,7 @@ request(DebugTag, URL, Headers, RequestBody, Method) ->
{Method, Path,
add_auth(MethodString, Path, Headers,
RequestBody),
- RequestBody}),
+ {fun chunk_data/1, RequestBody}}),
lager:debug("~s: received headers for ~p: ~p",
[DebugTag, URL, RespHeaders]),
{ok, Body} = hackney:body(ClientRef),
diff --git a/src/storage.erl b/src/storage.erl
index c64d918..7498635 100644
--- a/src/storage.erl
+++ b/src/storage.erl
@@ -37,7 +37,7 @@ request(post, ?APPURL_PLOP_STORAGE, "entrycommitted", Input) ->
undefined ->
none;
TimestampSignature ->
- plop:add_spt(LeafHash, base64:decode(TimestampSignature))
+ plop:add_spt_sig(LeafHash, base64:decode(TimestampSignature))
end,
success({[{result, <<"ok">>}]})
end;