瀏覽代碼

Bug fix for spurious timeout messages being sent to the client in certain cases. Other cleanup

pull/150/head v4.3
Chandru Mullaparthi 9 年之前
父節點
當前提交
b28542d1e3
共有 10 個檔案被更改,包括 1334 行新增51 行删除
  1. +1
    -0
      .travis.yml
  2. +8
    -0
      CHANGELOG
  3. +5
    -35
      Makefile
  4. +1
    -1
      README.md
  5. +1279
    -0
      erlang.mk
  6. +2
    -1
      src/ibrowse.app.src
  7. +6
    -5
      src/ibrowse.erl
  8. +9
    -4
      src/ibrowse_http_client.erl
  9. +22
    -3
      src/ibrowse_lib.erl
  10. +1
    -2
      test/Makefile

+ 1
- 0
.travis.yml 查看文件

@ -6,6 +6,7 @@ otp_release:
- 17.1
- 18.0
- 18.1
- 18.2.1
before_script:
- "./bootstrap_travis.sh"
script: "./rebar3 eunit"

+ 8
- 0
CHANGELOG 查看文件

@ -1,6 +1,14 @@
CONTRIBUTIONS & CHANGE HISTORY
==============================
07-06-2016 - v4.3
* Adopted erlang.mk for compiling. I find it easier to understand
how 'make' behaves compared to rebar. This repo can still be built
using rebar for those who prefer it
* Removed references to lager. Introduced configurable logging function
* Fixed an issue where the calling process was getting an extra
spurious timeout message when the request was timing out
19-04-2016 - v4.2.4
* Fixed travis-ci build as it was failing in running tests.
No code changes to ibrowse

+ 5
- 35
Makefile 查看文件

@ -1,19 +1,10 @@
IBROWSE_VSN = $(shell sed -n 's/.*{vsn,.*"\(.*\)"}.*/\1/p' src/ibrowse.app.src)
PROJECT=ibrowse
PLT_APPS=erts kernel stdlib ssl crypto public_key
TEST_ERLC_OPTS=-pa ../ibrowse/ebin
DIALYZER_PLT=$(CURDIR)/.dialyzer_plt
DIALYZER_APPS=erts kernel stdlib ssl crypto public_key
include erlang.mk
REBAR ?= $(shell which rebar3)
all: compile
compile:
$(REBAR) compile
clean:
@$(REBAR) clean && cd test && make clean && cd ..
test: compile unit_tests eunit
test: app eunit unit_tests old_tests
@echo "====================================================="
unit_tests:
@ -25,24 +16,3 @@ old_tests:
@echo "====================================================="
@echo "Running old tests..."
@cd test && make old_tests && cd ..
eunit:
@echo "====================================================="
@echo "Running eunit tests..."
$(REBAR) eunit
xref: all
$(REBAR) xref
docs:
$(REBAR) edoc
dialyzer:
$(REBAR) dialyzer
install: compile
mkdir -p $(DESTDIR)/lib/ibrowse-$(IBROWSE_VSN)/
cp -r _build/lib/default/ibrowse/ebin $(DESTDIR)/lib/ibrowse-$(IBROWSE_VSN)/
.PHONY: test docs

+ 1
- 1
README.md 查看文件

@ -7,7 +7,7 @@ ibrowse is a HTTP client written in erlang.
**Comments to:** chandrashekhar.mullaparthi@gmail.com
**Current Version:** 4.2.4
**Current Version:** 4.3
**Latest Version:** git://github.com/cmullaparthi/ibrowse.git

+ 1279
- 0
erlang.mk
文件差異過大導致無法顯示
查看文件


+ 2
- 1
src/ibrowse.app.src 查看文件

@ -1,12 +1,13 @@
{application, ibrowse,
[{description, "Erlang HTTP client application"},
{vsn, "4.2.4"},
{vsn, "4.3"},
{registered, [ibrowse_sup, ibrowse]},
{applications, [kernel,stdlib]},
{env, []},
{mod, {ibrowse_app, []}},
{maintainers, ["Chandrashekhar Mullaparthi"]},
{licenses, ["GPLv2", "BSD"]},
{modules, []},
{links, [{"Github", "https://github.com/cmullaparthi/ibrowse"}]}
]
}.

+ 6
- 5
src/ibrowse.erl 查看文件

@ -111,7 +111,8 @@
-import(ibrowse_lib, [
parse_url/1,
get_value/3,
do_trace/2
do_trace/2,
log_msg/2
]).
-record(state, {trace = false}).
@ -496,12 +497,12 @@ do_send_req(Conn_Pid, Parsed_url, Headers, Method, Body, Options, Timeout) ->
_ ->
process_info_not_available
end,
(catch lager:error("{ibrowse_http_client, send_req, ~1000.p} gen_server call timeout.~nProcess info: ~p~n",
[[Conn_Pid, Parsed_url, Headers, Method, Body, Options, Timeout], P_info])),
log_msg("{ibrowse_http_client, send_req, ~1000.p} gen_server call timeout.~nProcess info: ~p~n",
[[Conn_Pid, Parsed_url, Headers, Method, Body, Options, Timeout], P_info]),
{error, req_timedout};
{'EXIT', {normal, _}} = Ex_rsn ->
(catch lager:error("{ibrowse_http_client, send_req, ~1000.p} gen_server call got ~1000.p~n",
[[Conn_Pid, Parsed_url, Headers, Method, Body, Options, Timeout], Ex_rsn])),
log_msg("{ibrowse_http_client, send_req, ~1000.p} gen_server call got ~1000.p~n",
[[Conn_Pid, Parsed_url, Headers, Method, Body, Options, Timeout], Ex_rsn]),
{error, req_timedout};
{error, X} when X == connection_closed;
X == {send_failed, {error, enotconn}};

+ 9
- 4
src/ibrowse_http_client.erl 查看文件

@ -262,17 +262,22 @@ handle_info({ssl_error, _Sock, Reason}, State) ->
delayed_stop_timer(),
{noreply, State_1};
handle_info({req_timedout, From}, State) ->
case lists:keysearch(From, #request.from, queue:to_list(State#state.reqs)) of
handle_info({req_timedout, From}, #state{reqs = Reqs} = State) ->
Reqs_list = queue:to_list(Reqs),
case lists:keysearch(From, #request.from, Reqs_list) of
false ->
{noreply, State};
{value, #request{stream_to = StreamTo, req_id = ReqId}} ->
catch StreamTo ! {ibrowse_async_response_timeout, ReqId},
State_1 = State#state{proc_state = ?dead_proc_walking},
shutting_down(State_1),
do_error_reply(State_1, req_timedout),
Reqs_1 = lists:filter(fun(#request{from = X_from}) ->
X_from /= From
end, Reqs_list),
State_2 = State_1#state{reqs = queue:from_list(Reqs_1)},
do_error_reply(State_2, req_timedout),
delayed_stop_timer(),
{noreply, State_1}
{noreply, State_2}
end;
handle_info(timeout, State) ->

+ 22
- 3
src/ibrowse_lib.erl 查看文件

@ -20,6 +20,7 @@
get_trace_status/2,
do_trace/2,
do_trace/3,
log_msg/2,
url_encode/1,
decode_rfc822_date/1,
status_code/1,
@ -398,13 +399,31 @@ do_trace(_, Fmt, Args) ->
get(ibrowse_trace_token) | Args]).
-else.
do_trace(true, Fmt, Args) ->
io:format("~s -- (~s) - "++Fmt,
[printable_date(),
get(ibrowse_trace_token) | Args]);
Fmt_1 = "~s -- (~s) - "++Fmt,
Args_1 = [printable_date(),
get(ibrowse_trace_token) | Args],
case application:get_env(ibrowse, logger_mf) of
{ok, {M, F}} ->
log_msg(M, F, Fmt_1, Args_1);
_ ->
log_msg(io, format, Fmt_1, Args_1)
end;
do_trace(_, _, _) ->
ok.
-endif.
log_msg(Fmt, Args) ->
case application:get_env(ibrowse, logger_mf) of
{ok, {M, F}} ->
log_msg(M, F, Fmt, Args),
ok;
_ ->
ok
end.
log_msg(M, F, Fmt, Args) ->
catch apply(M, F, [Fmt, Args]).
-ifdef(EUNIT).
parse_url_test() ->

+ 1
- 2
test/Makefile 查看文件

@ -1,5 +1,4 @@
REBAR ?= $(shell which rebar3)
IBROWSE_EBIN_PATH=../_build/default/lib/ibrowse/ebin
IBROWSE_EBIN_PATH=../../ibrowse/ebin
compile:
@erl -pa $(IBROWSE_EBIN_PATH) -make

Loading…
取消
儲存