Skip to content

Commit

Permalink
Fix for case when chunk trailer spans two TCP packets provided by Mat…
Browse files Browse the repository at this point in the history
…thew Reilly.
  • Loading branch information
chandrusf committed Oct 19, 2007
1 parent 4fddbae commit 3d448b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions lib/ibrowse/README
Expand Up @@ -22,6 +22,11 @@ Comments to : Chandrashekhar.Mullaparthi@t-mobile.co.uk

CONTRIBUTIONS & CHANGE HISTORY
==============================
17-10-2007 - Matthew Reilly (matthew dot reilly _at_ sipphone dot com)
sent a bug report and a fix. If the chunk trailer spans two TCP
packets, then ibrowse fails to recognise that the chunked transfer
has ended.

29-08-2007 - Bug report by Peter Kristensen(ptx _at_ daimi dot au dot dk).
ibrowse crashes when the webserver returns just the Status line
and nothing else.
Expand Down
11 changes: 7 additions & 4 deletions lib/ibrowse/src/ibrowse_http_client.erl
Expand Up @@ -761,7 +761,7 @@ parse_11_response(DataRecvd,
chunk_size=ChunkSize})
end;
{no, Data_1} ->
State#state{reply_buffer=Data_1}
State#state{reply_buffer=Data_1, rep_buf_size=length(Data_1)}
end;

%% This clause is there to remove the CRLF between two chunks
Expand All @@ -778,7 +778,10 @@ parse_11_response(DataRecvd,
%%
%% Do we have to preserve the chunk encoding when streaming?
%%
State_1 = State#state{chunk_size=chunk_start, deleted_crlf=true},
State_1 = State#state{chunk_size=chunk_start,
rep_buf_size=0,
reply_buffer=[],
deleted_crlf=true},
State_2 = case StreamTo of
undefined ->
State_1#state{chunks = [Buf | Chunks]};
Expand All @@ -788,7 +791,7 @@ parse_11_response(DataRecvd,
end,
parse_11_response(NextChunk, State_2);
{no, Data_1} ->
State#state{reply_buffer=Data_1}
State#state{reply_buffer=Data_1, rep_buf_size=length(Data_1)}
end;

%% This clause deals with the end of a chunked transfer
Expand All @@ -815,7 +818,7 @@ parse_11_response(DataRecvd,
State_1 = handle_response(CurReq, State#state{reqs=Reqs_1}),
parse_response(Rem, reset_state(State_1));
{no, Rem} ->
State#state{reply_buffer=Rem, rep_buf_size=length(Rem), chunk_size=tbd}
State#state{reply_buffer=Rem, rep_buf_size=length(Rem), deleted_crlf=false}
end;

%% This clause extracts a chunk, given the size.
Expand Down

0 comments on commit 3d448b8

Please sign in to comment.