Permalink
Browse files

Fix for case when chunk trailer spans two TCP packets provided by Mat…

…thew Reilly.
  • Loading branch information...
1 parent 4fddbae commit 3d448b8f3a9dc3e92ae4ec231e0e59e7b7b84cea chandrusf committed Oct 19, 2007
Showing with 12 additions and 4 deletions.
  1. +5 −0 lib/ibrowse/README
  2. +7 −4 lib/ibrowse/src/ibrowse_http_client.erl
View
@@ -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.
@@ -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
@@ -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]};
@@ -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
@@ -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.

0 comments on commit 3d448b8

Please sign in to comment.