Procházet zdrojové kódy

Various changes. See README for details

pull/35/head
Chandrashekhar Mullaparthi před 14 roky
rodič
revize
74c337792a
9 změnil soubory, kde provedl 77 přidání a 31 odebrání
  1. +2
    -1
      Makefile
  2. +18
    -1
      README
  3. +1
    -1
      ebin/ibrowse.app
  4. +1
    -1
      src/Makefile
  5. +9
    -9
      src/ibrowse.erl
  6. +16
    -13
      src/ibrowse_http_client.erl
  7. +21
    -0
      test/Makefile
  8. +8
    -4
      test/ibrowse_test_server.erl
  9. +1
    -1
      vsn.mk

+ 2
- 1
Makefile Zobrazit soubor

@ -2,6 +2,7 @@ include vsn.mk
all:
(cd src ; make)
(cd test ; make)
clean:
(cd src ; make clean)
@ -11,7 +12,7 @@ install: all
cp -r ebin $(DESTDIR)/lib/ibrowse-$(IBROWSE_VSN)/
test: all
erl -noshell -pa ebin -s ibrowse -s ibrowse_test unit_tests \
erl -noshell -pa ebin -pa test -s ibrowse -s ibrowse_test unit_tests \
-s ibrowse_test verify_chunked_streaming \
-s ibrowse_test test_chunked_streaming_once \
-s erlang halt

+ 18
- 1
README Zobrazit soubor

@ -18,7 +18,7 @@ ibrowse is available under two different licenses. LGPL or the BSD license.
Comments to : Chandrashekhar.Mullaparthi@gmail.com
Version : 2.1.2
Version : 2.1.3
Latest version : git://github.com/cmullaparthi/ibrowse.git
@ -56,10 +56,27 @@ Seth Falcon
Steve Vinoski
Thomas Lindgren
Younès Hafri
fholzhauser (https://github.com/fholzhauser/)
tholschuh (https://github.com/tholschuh/)
CONTRIBUTIONS & CHANGE HISTORY
==============================
16-01-2011 - v2.1.3
* Fixed issues with streaming and chunked responses when using
the 'caller controls socket' feature. See following links for
details. Contributed by Filipe David Manana.
https://github.com/cmullaparthi/ibrowse/pull/24
https://github.com/cmullaparthi/ibrowse/pull/25
https://github.com/cmullaparthi/ibrowse/pull/27
https://github.com/cmullaparthi/ibrowse/pull/28
https://github.com/cmullaparthi/ibrowse/pull/29
* Fix for issue 32 reported by fholzhauser
https://github.com/cmullaparthi/ibrowse/issues#issue/32
* Fixed some dialyzer warnings. Thanks to Kostis for reporting
them.
20-12-2010 - v2.1.2
* Pipelining wasn't working when used in conjunction with the
{stream_to, {self(), once}} option. Bug report by

+ 1
- 1
ebin/ibrowse.app Zobrazit soubor

@ -1,6 +1,6 @@
{application, ibrowse,
[{description, "HTTP client application"},
{vsn, "2.1.2"},
{vsn, "2.1.3"},
{modules, [ ibrowse,
ibrowse_http_client,
ibrowse_app,

+ 1
- 1
src/Makefile Zobrazit soubor

@ -13,7 +13,7 @@ INCLUDE_DIRS = -I./
ERLC ?= erlc
ERLC_EMULATOR ?= erl -boot start_clean
COMPILER_OPTIONS = -W +warn_unused_vars +nowarn_shadow_vars +warn_unused_import
COMPILER_OPTIONS = -W +debug_info +warn_unused_vars +nowarn_shadow_vars +warn_unused_import
.SUFFIXES: .erl .beam $(SUFFIXES)
EBIN = ../ebin

+ 9
- 9
src/ibrowse.erl Zobrazit soubor

@ -6,8 +6,8 @@
%%% Created : 11 Oct 2003 by Chandrashekhar Mullaparthi <chandrashekhar.mullaparthi@t-mobile.co.uk>
%%%-------------------------------------------------------------------
%% @author Chandrashekhar Mullaparthi <chandrashekhar dot mullaparthi at gmail dot com>
%% @copyright 2005-2010 Chandrashekhar Mullaparthi
%% @version 2.1.2
%% @copyright 2005-2011 Chandrashekhar Mullaparthi
%% @version 2.1.3
%% @doc The ibrowse application implements an HTTP 1.1 client in erlang. 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
@ -683,16 +683,16 @@ init(_) ->
State = #state{},
put(my_trace_flag, State#state.trace),
put(ibrowse_trace_token, "ibrowse"),
ets:new(ibrowse_lb, [named_table, public, {keypos, 2}]),
ets:new(ibrowse_conf, [named_table, protected, {keypos, 2}]),
ets:new(ibrowse_stream, [named_table, public]),
ibrowse_lb = ets:new(ibrowse_lb, [named_table, public, {keypos, 2}]),
ibrowse_conf = ets:new(ibrowse_conf, [named_table, protected, {keypos, 2}]),
ibrowse_stream = ets:new(ibrowse_stream, [named_table, public]),
import_config(),
{ok, #state{}}.
import_config() ->
case code:priv_dir(ibrowse) of
{error, _} = Err ->
Err;
{error, _} ->
ok;
PrivDir ->
Filename = filename:join(PrivDir, "ibrowse.conf"),
import_config(Filename)
@ -723,8 +723,8 @@ import_config(Filename) ->
io:format("Skipping unrecognised term: ~p~n", [X])
end,
lists:foreach(Fun, Terms);
Err ->
Err
_Err ->
ok
end.
%% @doc Internal export

+ 16
- 13
src/ibrowse_http_client.erl Zobrazit soubor

@ -216,12 +216,14 @@ handle_info({ssl_closed, _Sock}, State) ->
handle_sock_closed(State),
{stop, normal, State};
handle_info({tcp_error, _Sock}, State) ->
do_trace("Error on connection to ~1000.p:~1000.p~n", [State#state.host, State#state.port]),
handle_info({tcp_error, _Sock, Reason}, State) ->
do_trace("Error on connection to ~1000.p:~1000.p -> ~1000.p~n",
[State#state.host, State#state.port, Reason]),
handle_sock_closed(State),
{stop, normal, State};
handle_info({ssl_error, _Sock}, State) ->
do_trace("Error on SSL connection to ~1000.p:~1000.p~n", [State#state.host, State#state.port]),
handle_info({ssl_error, _Sock, Reason}, State) ->
do_trace("Error on SSL connection to ~1000.p:~1000.p -> ~1000.p~n",
[State#state.host, State#state.port, Reason]),
handle_sock_closed(State),
{stop, normal, State};
@ -466,7 +468,7 @@ handle_sock_closed(#state{reply_buffer = Buf, reqs = Reqs, http_status_code = SC
undefined ->
Buf;
_ ->
file:close(Fd),
ok = file:close(Fd),
{file, TmpFilename}
end,
Reply = case get_value(give_raw_headers, Options, false) of
@ -475,11 +477,11 @@ handle_sock_closed(#state{reply_buffer = Buf, reqs = Reqs, http_status_code = SC
false ->
{ok, SC, Headers, Buf}
end,
do_reply(State, From, StreamTo, ReqId, Resp_format, Reply),
do_error_reply(State#state{reqs = Reqs_1}, connection_closed),
State;
State_1 = do_reply(State, From, StreamTo, ReqId, Resp_format, Reply),
ok = do_error_reply(State_1#state{reqs = Reqs_1}, connection_closed),
State_1;
_ ->
do_error_reply(State, connection_closed),
ok = do_error_reply(State, connection_closed),
State
end.
@ -1276,7 +1278,7 @@ handle_response(#request{from=From, stream_to=StreamTo, req_id=ReqId,
reply_buffer = RepBuf,
recvd_headers = RespHeaders}=State) when SaveResponseToFile /= false ->
Body = RepBuf,
file:close(Fd),
ok = file:close(Fd),
ResponseBody = case TmpFilename of
undefined ->
Body;
@ -1663,8 +1665,8 @@ fail_pipelined_requests(#state{reqs = Reqs, cur_req = CurReq} = State, Reply) ->
{_, Reqs_1} = queue:out(Reqs),
#request{from=From, stream_to=StreamTo, req_id=ReqId,
response_format = Resp_format} = CurReq,
do_reply(State, From, StreamTo, ReqId, Resp_format, Reply),
do_error_reply(State#state{reqs = Reqs_1}, previous_request_failed).
State_1 = do_reply(State, From, StreamTo, ReqId, Resp_format, Reply),
do_error_reply(State_1#state{reqs = Reqs_1}, previous_request_failed).
split_list_at(List, N) ->
split_list_at(List, N, []).
@ -1708,7 +1710,8 @@ to_ascii($9) -> 9;
to_ascii($0) -> 0.
cancel_timer(undefined) -> ok;
cancel_timer(Ref) -> erlang:cancel_timer(Ref).
cancel_timer(Ref) -> _ = erlang:cancel_timer(Ref),
ok.
cancel_timer(Ref, {eat_message, Msg}) ->
cancel_timer(Ref),

+ 21
- 0
test/Makefile Zobrazit soubor

@ -0,0 +1,21 @@
include ../vsn.mk
ERL_FILES = ibrowse_test_server.erl
INCLUDE_DIRS = -I./
ERLC ?= erlc
ERLC_EMULATOR ?= erl -boot start_clean
COMPILER_OPTIONS = -W +warn_unused_vars +nowarn_shadow_vars +warn_unused_import
.SUFFIXES: .erl .beam $(SUFFIXES)
all: $(ERL_FILES:%.erl=%.beam)
%.beam: %.erl
${ERLC} $(COMPILER_OPTIONS) $(INCLUDE_DIRS) -o ./ $<
clean:
rm -f *.beam

+ 8
- 4
test/ibrowse_test_server.erl Zobrazit soubor

@ -17,18 +17,22 @@ start_server(Port, Sock_type) ->
Fun = fun() ->
register(server_proc_name(Port), self()),
case do_listen(Sock_type, Port, [{active, false},
{reuseaddr, true},
{nodelay, true},
{packet, http}]) of
{ok, Sock} ->
do_trace("Server listening on port: ~p~n", [Port]),
accept_loop(Sock, Sock_type);
Err ->
do_trace("Failed to start server on port ~p. ~p~n",
[Port, Err]),
Err
erlang:error(
lists:flatten(
io_lib:format(
"Failed to start server on port ~p. ~p~n",
[Port, Err]))),
exit({listen_error, Err})
end
end,
spawn(Fun).
spawn_link(Fun).
stop_server(Port) ->
exit(whereis(server_proc_name(Port)), kill).

+ 1
- 1
vsn.mk Zobrazit soubor

@ -1,2 +1,2 @@
IBROWSE_VSN = 2.1.2
IBROWSE_VSN = 2.1.3

Načítá se…
Zrušit
Uložit