aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/http_client/httpc_handler.erl
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2010-03-19 14:48:15 +0000
committerErlang/OTP <[email protected]>2010-03-19 14:48:15 +0000
commitc9f480b49256e1f7869265e4346c594fa4f90fd5 (patch)
tree0835a66f6b79fa7902f359b4c02fded09bfc8ace /lib/inets/src/http_client/httpc_handler.erl
parentd98796f44dfd874b8a9887d60c8367386198d4cc (diff)
downloadotp-c9f480b49256e1f7869265e4346c594fa4f90fd5.tar.gz
otp-c9f480b49256e1f7869265e4346c594fa4f90fd5.tar.bz2
otp-c9f480b49256e1f7869265e4346c594fa4f90fd5.zip
OTP-8508 & OTP-8509.
Diffstat (limited to 'lib/inets/src/http_client/httpc_handler.erl')
-rw-r--r--lib/inets/src/http_client/httpc_handler.erl35
1 files changed, 26 insertions, 9 deletions
diff --git a/lib/inets/src/http_client/httpc_handler.erl b/lib/inets/src/http_client/httpc_handler.erl
index 31585537d4..695ff9cf82 100644
--- a/lib/inets/src/http_client/httpc_handler.erl
+++ b/lib/inets/src/http_client/httpc_handler.erl
@@ -280,7 +280,7 @@ handle_call({connect_and_send, #request{address = Address0,
{ok, NewState} ->
{reply, ok, NewState};
{stop, Error, NewState} ->
- {stop, Error, Error, NewState}
+ {stop, normal, Error, NewState}
end
end;
@@ -675,6 +675,24 @@ handle_info({'EXIT', _, _}, State) ->
%%--------------------------------------------------------------------
%% Init error there is no socket to be closed.
+terminate(normal,
+ #state{request = Request,
+ session = {send_failed, AReason} = Reason} = State) ->
+ ?hcrd("terminate", [{send_reason, AReason}, {request, Request}]),
+ maybe_send_answer(Request,
+ httpc_response:error(Request, Reason),
+ State),
+ ok;
+
+terminate(normal,
+ #state{request = Request,
+ session = {connect_failed, AReason} = Reason} = State) ->
+ ?hcrd("terminate", [{connect_reason, AReason}, {request, Request}]),
+ maybe_send_answer(Request,
+ httpc_response:error(Request, Reason),
+ State),
+ ok;
+
terminate(normal, #state{session = undefined}) ->
ok;
@@ -886,18 +904,17 @@ connect_and_send_first_request(Address,
NewState = activate_request_timeout(TmpState),
{ok, NewState};
- {error, Reason} ->
+ {error, Reason} = Error ->
?hcrv("failed sending request", [{reason, Reason}]),
- Error = {error, {send_failed,
- httpc_response:error(Request, Reason)}},
- {stop, Error, State#state{request = Request}}
+ {stop, Error,
+ State#state{session = {send_failed, Reason},
+ request = Request}}
end;
- {error, Reason} ->
+ {error, Reason} = Error ->
?hcri("connect failed", [{reason, Reason}]),
- Error = {error, {connect_failed,
- httpc_response:error(Request, Reason)}},
- {stop, Error, State#state{request = Request}}
+ {stop, Error, State#state{session = {connect_failed, Reason},
+ request = Request}}
end.