Ver a proveniência

Fixed bug in processing of save_response_to_file option

pull/16/head
Chandrashekhar Mullaparthi há 15 anos
ascendente
cometimento
75bab56e5d
4 ficheiros alterados com 18 adições e 12 eliminações
  1. +5
    -1
      README
  2. +1
    -1
      src/ibrowse.erl
  3. +11
    -9
      src/ibrowse_http_client.erl
  4. +1
    -1
      vsn.mk

+ 5
- 1
README Ver ficheiro

@ -18,12 +18,16 @@ ibrowse is available under two different licenses. LGPL and the BSD license.
Comments to : Chandrashekhar.Mullaparthi@gmail.com
Version : 1.5.3
Version : 1.5.4
Latest version : git://github.com/cmullaparthi/ibrowse.git
CONTRIBUTIONS & CHANGE HISTORY
==============================
24-09-2009 - * When a filename was supplied with the 'save_response_to_file'
option, the option was being ignored. Bug report from
Adam Kocoloski
05-09-2009 - * Introduced option to allow caller to set socket options.
29-07-2009 - * The ETS table created for load balancing of requests was not

+ 1
- 1
src/ibrowse.erl Ver ficheiro

@ -7,7 +7,7 @@
%%%-------------------------------------------------------------------
%% @author Chandrashekhar Mullaparthi <chandrashekhar dot mullaparthi at gmail dot com>
%% @copyright 2005-2009 Chandrashekhar Mullaparthi
%% @version 1.5.2
%% @version 1.5.4
%% @doc The ibrowse application implements an HTTP 1.1 client. This
%% module implements the API of the HTTP client. There is one named
%% process called 'ibrowse' which assists in load balancing and maintaining configuration. There is one load balancing process per unique webserver. There is

+ 11
- 9
src/ibrowse_http_client.erl Ver ficheiro

@ -297,10 +297,10 @@ handle_sock_data(Data, #state{status = get_body,
accumulate_response(Data,
#state{
cur_req = #request{save_response_to_file = true,
cur_req = #request{save_response_to_file = Srtf,
tmp_file_fd = undefined} = CurReq,
http_status_code=[$2 | _]}=State) ->
TmpFilename = make_tmp_filename(),
http_status_code=[$2 | _]}=State) when Srtf /= false ->
TmpFilename = make_tmp_filename(Srtf),
case file:open(TmpFilename, [write, delayed_write, raw]) of
{ok, Fd} ->
accumulate_response(Data, State#state{
@ -310,23 +310,23 @@ accumulate_response(Data,
{error, Reason} ->
{error, {file_open_error, Reason}}
end;
accumulate_response(Data, #state{cur_req = #request{save_response_to_file = true,
accumulate_response(Data, #state{cur_req = #request{save_response_to_file = Srtf,
tmp_file_fd = Fd},
transfer_encoding=chunked,
reply_buffer = Reply_buf,
http_status_code=[$2 | _]
} = State) ->
} = State) when Srtf /= false ->
case file:write(Fd, [Reply_buf, Data]) of
ok ->
State#state{reply_buffer = <<>>};
{error, Reason} ->
{error, {file_write_error, Reason}}
end;
accumulate_response(Data, #state{cur_req = #request{save_response_to_file = true,
accumulate_response(Data, #state{cur_req = #request{save_response_to_file = Srtf,
tmp_file_fd = Fd},
reply_buffer = RepBuf,
http_status_code=[$2 | _]
} = State) ->
} = State) when Srtf /= false ->
case file:write(Fd, [RepBuf, Data]) of
ok ->
State#state{reply_buffer = <<>>};
@ -364,14 +364,16 @@ accumulate_response(Data, #state{reply_buffer = RepBuf,
State#state{reply_buffer = RepBuf_1}
end.
make_tmp_filename() ->
make_tmp_filename(true) ->
DownloadDir = ibrowse:get_config_value(download_dir, filename:absname("./")),
{A,B,C} = now(),
filename:join([DownloadDir,
"ibrowse_tmp_file_"++
integer_to_list(A) ++
integer_to_list(B) ++
integer_to_list(C)]).
integer_to_list(C)]);
make_tmp_filename(File) when is_list(File) ->
File.
%%--------------------------------------------------------------------

+ 1
- 1
vsn.mk Ver ficheiro

@ -1,2 +1,2 @@
IBROWSE_VSN = 1.5.3
IBROWSE_VSN = 1.5.4

Carregando…
Cancelar
Guardar