From cf3c624dc66a42d9d7bec904d8be3b8c4cce38ae Mon Sep 17 00:00:00 2001 From: Sergey Sinkovskiy Date: Wed, 30 Apr 2014 09:57:51 +0300 Subject: inets: Fix streaming with single chunk body Receiving HTTP response with chunked transfer encoding in a single TCP message should produce stream messages for response body when streaming mode is used for httpc. --- lib/inets/src/http_client/httpc_handler.erl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/inets/src/http_client') diff --git a/lib/inets/src/http_client/httpc_handler.erl b/lib/inets/src/http_client/httpc_handler.erl index 80c8b2439e..32d20b62d1 100644 --- a/lib/inets/src/http_client/httpc_handler.erl +++ b/lib/inets/src/http_client/httpc_handler.erl @@ -1116,8 +1116,16 @@ handle_http_body(Body, #state{headers = Headers, {new_body, NewBody}]), NewHeaders = http_chunk:handle_headers(Headers, ChunkedHeaders), - handle_response(State#state{headers = NewHeaders, - body = NewBody}) + case Body of + <<>> -> + handle_response(State#state{headers = NewHeaders, + body = NewBody}); + _ -> + {NewBody2, NewRequest} = + stream(NewBody, Request, Code), + handle_response(State#state{headers = NewHeaders, + body = NewBody2}) + end end; Encoding when is_list(Encoding) -> ?hcrt("handle_http_body - encoding", [{encoding, Encoding}]), -- cgit v1.2.3