From a027c412d7cb6cf6ad00422b7dfd8534bf8c212b Mon Sep 17 00:00:00 2001 From: Kirilll Zaborsky Date: Fri, 16 May 2014 17:23:43 +0400 Subject: inets: Fix HTTP 1.0 body end on closed connection Receiving HTTP response with no Content-length header and with body ending on closed connection should give the complete response body contents up to the last byte received. --- lib/inets/src/http_client/httpc_handler.erl | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/inets/src') diff --git a/lib/inets/src/http_client/httpc_handler.erl b/lib/inets/src/http_client/httpc_handler.erl index 32d20b62d1..93bcb6c3e8 100644 --- a/lib/inets/src/http_client/httpc_handler.erl +++ b/lib/inets/src/http_client/httpc_handler.erl @@ -1226,6 +1226,7 @@ handle_response(#state{request = Request, handle_queue(State#state{request = undefined}, Data); {ok, Msg, Data} -> ?hcrd("handle response - ok", []), + stream_remaining_body(Body, Request, StatusLine), end_stream(StatusLine, Request), NewState = maybe_send_answer(Request, Msg, State), handle_queue(NewState, Data); @@ -1634,6 +1635,10 @@ start_stream(_StatusLine, _Headers, Request) -> ?hcrt("start stream - no op", []), {ok, Request}. +stream_remaining_body(<<>>, _, _) -> + ok; +stream_remaining_body(Body, Request, {_, Code, _}) -> + stream(Body, Request, Code). %% Note the end stream message is handled by httpc_response and will %% be sent by answer_request -- cgit v1.2.3