aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-03-27 10:52:10 +0100
committerLoïc Hoguin <[email protected]>2014-03-27 10:52:10 +0100
commit5b041ab160185efdbe8bb6a0811fc4de857d2d6c (patch)
tree7ce5ea7c3968e44fd2fd211b5f3816926ab2ec93
parentdbc14259d6d8bfef50cc0e7253d07ed322fd9239 (diff)
downloadcowlib-5b041ab160185efdbe8bb6a0811fc4de857d2d6c.tar.gz
cowlib-5b041ab160185efdbe8bb6a0811fc4de857d2d6c.tar.bz2
cowlib-5b041ab160185efdbe8bb6a0811fc4de857d2d6c.zip
Add cow_http_te:decode_ret() type and simplify it a little
-rw-r--r--src/cow_http_te.erl12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/cow_http_te.erl b/src/cow_http_te.erl
index aa9c6b9..5c23fad 100644
--- a/src/cow_http_te.erl
+++ b/src/cow_http_te.erl
@@ -26,6 +26,14 @@
%% The state type is the same for both identity and chunked.
-type state() :: {non_neg_integer(), non_neg_integer()}.
+-type decode_ret() :: more
+ | {more, Data::binary(), state()}
+ | {more, Data::binary(), RemLen::non_neg_integer(), state()}
+ | {more, Data::binary(), Rest::binary(), state()}
+ | {done, TotalLen::non_neg_integer(), Rest::binary()}
+ | {done, Data::binary(), TotalLen::non_neg_integer(), Rest::binary()}.
+-export_type([decode_ret/0]).
+
-ifdef(EXTRA).
dripfeed(<< C, Rest/bits >>, Acc, State, F) ->
case F(<< Acc/binary, C >>, State) of
@@ -122,7 +130,7 @@ horse_stream_identity_dripfeed() ->
-spec stream_chunked(Data, State)
-> more | {more, Data, State} | {more, Data, Len, State}
- | {more, Data, Len, Data, State}
+ | {more, Data, Data, State}
| {done, Len, Data} | {done, Data, Len, Data}
when Data::binary(), State::state(), Len::non_neg_integer().
stream_chunked(Data, State) ->
@@ -134,7 +142,7 @@ stream_chunked(Data = << C, _/bits >>, {0, Streamed}, Acc) when C =/= $\r ->
{next, Rest, State, Acc2} ->
stream_chunked(Rest, State, Acc2);
{more, State, Acc2} ->
- {more, Acc2, 0, Data, State};
+ {more, Acc2, Data, State};
Ret ->
Ret
end;