5
5
* | (__| |_| | _ <| |___
6
6
* \___|\___/|_| \_\_____|
8
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
8
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
10
10
* This software is licensed as described in the file COPYING, which
11
11
* you should have received as part of this distribution. The terms
90
87
* Curl_proxyCONNECT() requires that we're connected to a HTTP proxy. This
91
88
* function will issue the necessary commands to get a seamless tunnel through
92
89
* this proxy. After that, the socket can be used just as a normal socket.
94
* This badly needs to be rewritten. CONNECT should be sent and dealt with
95
* like any ordinary HTTP request, and not specially crafted like this. This
96
* function only remains here like this for now since the rewrite is a bit too
97
* much work to do at the moment.
99
* This function is BLOCKING which is nasty for all multi interface using apps.
102
92
CURLcode Curl_proxyCONNECT(struct connectdata *conn,
235
225
conn->tunnel_state[sockindex] = TUNNEL_CONNECT;
227
/* now we've issued the CONNECT and we're waiting to hear back, return
228
and get called again polling-style */
236
231
} /* END CONNECT PHASE */
238
/* now we've issued the CONNECT and we're waiting to hear back -
239
we try not to block here in multi-mode because that might be a LONG
240
wait if the proxy cannot connect-through to the remote host. */
242
/* if timeout is requested, find out how much remaining time we have */
243
check = timeout - /* timeout time */
244
Curl_tvdiff(Curl_tvnow(), conn->now); /* spent time */
246
failf(data, "Proxy CONNECT aborted due to timeout");
247
return CURLE_RECV_ERROR;
250
/* if we're in multi-mode and we would block, return instead for a retry */
251
if(Curl_if_multi == data->state.used_interface) {
252
if(0 == Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, 0))
253
/* return so we'll be called again polling-style */
257
"Multi mode finished polling for response from "
262
DEBUGF(infof(data, "Easy mode waiting response from proxy CONNECT\n"));
265
/* at this point, either:
266
1) we're in easy-mode and so it's okay to block waiting for a CONNECT
268
2) we're in multi-mode and we didn't block - it's either an error or we
269
now have some data waiting.
270
In any case, the tunnel_connecting phase is over. */
272
233
{ /* BEGIN NEGOTIATION PHASE */
273
234
size_t nread; /* total size read */
274
235
int perline; /* count bytes per line */
575
536
if(closeConnection && data->req.newurl)
576
537
conn->bits.proxy_connect_closed = TRUE;
539
if(data->req.newurl) {
540
/* this won't be used anymore for the CONNECT so free it now */
541
free(data->req.newurl);
542
data->req.newurl = NULL;
578
545
/* to back to init state */
579
546
conn->tunnel_state[sockindex] = TUNNEL_INIT;