aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/http_client/httpc_request.erl
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2010-01-19 17:04:24 +0000
committerErlang/OTP <[email protected]>2010-01-19 18:21:26 +0100
commitb408b344732b5a20d996d1cb88a40a3e46247271 (patch)
treeb7992f02f061490a1c34e6cc807c9a27befd181d /lib/inets/src/http_client/httpc_request.erl
parent10f031e7e6b497430918a29db97d12ffe37a5b2d (diff)
downloadotp-b408b344732b5a20d996d1cb88a40a3e46247271.tar.gz
otp-b408b344732b5a20d996d1cb88a40a3e46247271.tar.bz2
otp-b408b344732b5a20d996d1cb88a40a3e46247271.zip
OTP-8016 [httpc] Several more or less critical fixes: * Initial call
between the httpc manager and request handler was synchronous. When the manager starts a new request handler, this is no longer a synchronous operation. Previously, the new request handler made the connection to the server and issuing of the first request (the reason for starting it) in the gen_server init function. If the connection for some reason "took some time", the manager hanged, leaving all other activities by that manager also hanging. As a side-effect of these changes, some modules was also renamed, and a new api module, httpc, has been introduced (the old module, http, is *not* removed, but is now just wrapper for httpc).
Diffstat (limited to 'lib/inets/src/http_client/httpc_request.erl')
-rw-r--r--lib/inets/src/http_client/httpc_request.erl42
1 files changed, 28 insertions, 14 deletions
diff --git a/lib/inets/src/http_client/httpc_request.erl b/lib/inets/src/http_client/httpc_request.erl
index f15c5d4381..55e0af4b42 100644
--- a/lib/inets/src/http_client/httpc_request.erl
+++ b/lib/inets/src/http_client/httpc_request.erl
@@ -39,24 +39,37 @@
%%
%% Description: Composes and sends a HTTP-request.
%%-------------------------------------------------------------------------
-send(SendAddr, #request{method = Method,
- scheme = Scheme,
- path = Path,
- pquery = Query,
- headers = Headers,
- content = Content,
- address = Address,
- abs_uri = AbsUri,
- headers_as_is = HeadersAsIs,
- settings = HttpOptions,
- userinfo = UserInfo},
- Socket) ->
+send(SendAddr, #request{scheme = Scheme, socket_opts = SocketOpts} = Request,
+ Socket)
+ when is_list(SocketOpts) ->
+ SocketType = socket_type(Scheme),
+ case http_transport:setopts(SocketType, Socket, SocketOpts) of
+ ok ->
+ send(SendAddr, Socket, SocketType,
+ Request#request{socket_opts = undefined});
+ {error, Reason} ->
+ {error, {setopts_failed, Reason}}
+ end;
+send(SendAddr, #request{scheme = Scheme} = Request, Socket) ->
+ SocketType = socket_type(Scheme),
+ send(SendAddr, Socket, SocketType, Request).
+
+send(SendAddr, Socket, SocketType,
+ #request{method = Method,
+ path = Path,
+ pquery = Query,
+ headers = Headers,
+ content = Content,
+ address = Address,
+ abs_uri = AbsUri,
+ headers_as_is = HeadersAsIs,
+ settings = HttpOptions,
+ userinfo = UserInfo}) ->
?hcrt("send",
[{send_addr, SendAddr},
{socket, Socket},
{method, Method},
- {scheme, Scheme},
{path, Path},
{pquery, Query},
{headers, Headers},
@@ -95,7 +108,8 @@ send(SendAddr, #request{method = Method,
?hcrd("send", [{message, Message}]),
- http_transport:send(socket_type(Scheme), Socket, lists:append(Message)).
+ http_transport:send(SocketType, Socket, lists:append(Message)).
+
%%-------------------------------------------------------------------------