* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* This function might be called several times in the multi interface case
* if the proxy's CONNTECT response is not instant.
*/
- prot_save = conn->data->state.proto.generic;
+ prot_save = conn->data->req.protop;
memset(&http_proxy, 0, sizeof(http_proxy));
- conn->data->state.proto.http = &http_proxy;
- conn->bits.close = FALSE;
+ conn->data->req.protop = &http_proxy;
+ connkeep(conn, "HTTP proxy CONNECT");
result = Curl_proxyCONNECT(conn, FIRSTSOCKET,
conn->host.name, conn->remote_port);
- conn->data->state.proto.generic = prot_save;
+ conn->data->req.protop = prot_save;
if(CURLE_OK != result)
return result;
#else
CURLcode Curl_proxyCONNECT(struct connectdata *conn,
int sockindex,
const char *hostname,
- unsigned short remote_port)
+ int remote_port)
{
int subversion=0;
struct SessionHandle *data=conn->data;
return CURLE_OUT_OF_MEMORY;
}
- if(!Curl_checkheaders(data, "Host:")) {
+ if(!Curl_checkProxyheaders(conn, "Host:")) {
host = aprintf("Host: %s\r\n", hostheader);
if(!host) {
free(hostheader);
return CURLE_OUT_OF_MEMORY;
}
}
- if(!Curl_checkheaders(data, "Proxy-Connection:"))
+ if(!Curl_checkProxyheaders(conn, "Proxy-Connection:"))
proxyconn = "Proxy-Connection: Keep-Alive\r\n";
- if(!Curl_checkheaders(data, "User-Agent:") &&
+ if(!Curl_checkProxyheaders(conn, "User-Agent:") &&
data->set.str[STRING_USERAGENT])
useragent = conn->allocptr.uagent;
free(hostheader);
if(CURLE_OK == result)
- result = Curl_add_custom_headers(conn, req_buffer);
+ result = Curl_add_custom_headers(conn, TRUE, req_buffer);
if(CURLE_OK == result)
/* CRLF terminate the request */
return result;
conn->tunnel_state[sockindex] = TUNNEL_CONNECT;
- } /* END CONNECT PHASE */
-
- /* now we've issued the CONNECT and we're waiting to hear back -
- we try not to block here in multi-mode because that might be a LONG
- wait if the proxy cannot connect-through to the remote host. */
-
- /* if timeout is requested, find out how much remaining time we have */
- check = timeout - /* timeout time */
- Curl_tvdiff(Curl_tvnow(), conn->now); /* spent time */
- if(check <= 0) {
- failf(data, "Proxy CONNECT aborted due to timeout");
- return CURLE_RECV_ERROR;
- }
- if(0 == Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, 0))
- /* return so we'll be called again polling-style */
+ /* now we've issued the CONNECT and we're waiting to hear back, return
+ and get called again polling-style */
return CURLE_OK;
- else {
- DEBUGF(infof(data,
- "Multi mode finished polling for response from "
- "proxy CONNECT\n"));
- }
- /* at this point, either:
- 1) we're in easy-mode and so it's okay to block waiting for a CONNECT
- response
- 2) we're in multi-mode and we didn't block - it's either an error or we
- now have some data waiting.
- In any case, the tunnel_connecting phase is over. */
+ } /* END CONNECT PHASE */
{ /* BEGIN NEGOTIATION PHASE */
size_t nread; /* total size read */
result = Curl_client_write(conn, writetype, line_start,
perline);
+
+ data->info.header_size += (long)perline;
+ data->req.headerbytecount += (long)perline;
+
if(result)
return result;
keepon = 2;
if(cl) {
-
- infof(data, "Ignore %" FORMAT_OFF_T
+ infof(data, "Ignore %" CURL_FORMAT_CURL_OFF_T
" bytes of response-body\n", cl);
+
/* remove the remaining chunk of what we already
read */
cl -= (gotbytes - i);
(401 == k->httpcode)) ||
(checkprefix("Proxy-authenticate:", line_start) &&
(407 == k->httpcode))) {
- result = Curl_http_input_auth(conn, k->httpcode,
- line_start);
+
+ bool proxy = (k->httpcode == 407) ? TRUE : FALSE;
+ char *auth = Curl_copy_header_value(line_start);
+ if(!auth)
+ return CURLE_OUT_OF_MEMORY;
+
+ result = Curl_http_input_auth(conn, proxy, auth);
+
+ Curl_safefree(auth);
+
if(result)
return result;
}
infof (data, "Proxy replied OK to CONNECT request\n");
data->req.ignorebody = FALSE; /* put it (back) to non-ignore state */
+ conn->bits.rewindaftersend = FALSE; /* make sure this isn't set for the
+ document request */
return CURLE_OK;
}
#endif /* CURL_DISABLE_PROXY */