Skip to content

Commit

Permalink
parse trailers if needed in chunked encoding.
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitc committed Sep 25, 2012
1 parent 3e9c646 commit a553bdc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/hackney_response.erl
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ transfer_decode(Data, Client=#client{
content_decode(ContentDecode, Data2, Client#client{ content_decode(ContentDecode, Data2, Client#client{
buffer=Rest, body_state= buffer=Rest, body_state=
{stream, TransferDecode, TransferState2, ContentDecode}}); {stream, TransferDecode, TransferState2, ContentDecode}});
%% @todo {header(s) for chunked {chunk_done, Rest} ->
{ok, _, Client1} = stream_headers(Client#client{buffer=Rest}),
Client2 = transfer_decode_done(<<>>, Client1),
{done, Client2};

{chunk_ok, Chunk, Rest} -> {chunk_ok, Chunk, Rest} ->
{ok, Chunk, Client#client{buffer=Rest}}; {ok, Chunk, Client#client{buffer=Rest}};
more -> more ->
Expand Down Expand Up @@ -262,7 +266,7 @@ te_chunked(<<>>, _) ->
te_chunked(Data, _) -> te_chunked(Data, _) ->
case read_size(Data) of case read_size(Data) of
{ok, 0, Rest} -> {ok, 0, Rest} ->
{done, Rest}; {chunk_done, Rest};
{ok, Size, Rest} -> {ok, Size, Rest} ->
case read_chunk(Rest, Size) of case read_chunk(Rest, Size) of
{ok, Chunk, Rest1} -> {ok, Chunk, Rest1} ->
Expand Down Expand Up @@ -310,7 +314,7 @@ read_size(Data) ->
{ok, [Size], []} -> {ok, [Size], []} ->
{ok, Size, Rest}; {ok, Size, Rest};
_ -> _ ->
{error, {poorly_formatted_size, Line}} {error, {poorly_formatted_size, Line}}
end; end;
Err -> Err ->
Err Err
Expand Down

0 comments on commit a553bdc

Please sign in to comment.