Browse Source

Fix for case when chunk trailer spans two TCP packets provided by Matthew Reilly.

pull/16/head
chandrusf 17 years ago
parent
commit
b1cc0f2598
2 changed files with 14 additions and 6 deletions
  1. +6
    -1
      README
  2. +8
    -5
      src/ibrowse_http_client.erl

+ 6
- 1
README View File

@ -1,4 +1,4 @@
$Id: README,v 1.11 2007/10/09 00:02:30 chandrusf Exp $
$Id: README,v 1.12 2007/10/19 12:43:48 chandrusf Exp $
ibrowse is a HTTP client. The following are a list of features. ibrowse is a HTTP client. The following are a list of features.
- RFC2616 compliant (AFAIK) - RFC2616 compliant (AFAIK)
@ -22,6 +22,11 @@ Comments to : Chandrashekhar.Mullaparthi@t-mobile.co.uk
CONTRIBUTIONS & CHANGE HISTORY 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). 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 ibrowse crashes when the webserver returns just the Status line
and nothing else. and nothing else.

+ 8
- 5
src/ibrowse_http_client.erl View File

@ -6,7 +6,7 @@
%%% Created : 11 Oct 2003 by Chandrashekhar Mullaparthi <chandrashekhar.mullaparthi@t-mobile.co.uk> %%% Created : 11 Oct 2003 by Chandrashekhar Mullaparthi <chandrashekhar.mullaparthi@t-mobile.co.uk>
%%%------------------------------------------------------------------- %%%-------------------------------------------------------------------
-module(ibrowse_http_client). -module(ibrowse_http_client).
-vsn('$Id: ibrowse_http_client.erl,v 1.13 2007/10/09 00:02:30 chandrusf Exp $ ').
-vsn('$Id: ibrowse_http_client.erl,v 1.14 2007/10/19 12:43:48 chandrusf Exp $ ').
-behaviour(gen_server). -behaviour(gen_server).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
@ -761,7 +761,7 @@ parse_11_response(DataRecvd,
chunk_size=ChunkSize}) chunk_size=ChunkSize})
end; end;
{no, Data_1} -> {no, Data_1} ->
State#state{reply_buffer=Data_1}
State#state{reply_buffer=Data_1, rep_buf_size=length(Data_1)}
end; end;
%% This clause is there to remove the CRLF between two chunks %% 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? %% 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 State_2 = case StreamTo of
undefined -> undefined ->
State_1#state{chunks = [Buf | Chunks]}; State_1#state{chunks = [Buf | Chunks]};
@ -788,7 +791,7 @@ parse_11_response(DataRecvd,
end, end,
parse_11_response(NextChunk, State_2); parse_11_response(NextChunk, State_2);
{no, Data_1} -> {no, Data_1} ->
State#state{reply_buffer=Data_1}
State#state{reply_buffer=Data_1, rep_buf_size=length(Data_1)}
end; end;
%% This clause deals with the end of a chunked transfer %% 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}), State_1 = handle_response(CurReq, State#state{reqs=Reqs_1}),
parse_response(Rem, reset_state(State_1)); parse_response(Rem, reset_state(State_1));
{no, Rem} -> {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; end;
%% This clause extracts a chunk, given the size. %% This clause extracts a chunk, given the size.

Loading…
Cancel
Save