]> granicus.if.org Git - curl/commitdiff
url.c: fix HTTP CONNECT tunnel establishment upon delayed response
authorYang Tse <yangsita@gmail.com>
Thu, 17 Jan 2013 16:07:19 +0000 (17:07 +0100)
committerYang Tse <yangsita@gmail.com>
Thu, 17 Jan 2013 16:07:19 +0000 (17:07 +0100)
Fixes initial proxy response being processed by the tunneled protocol
handler instead of the HTTP wrapper handler. This issue would trigger
upon delayed CONNECT response from the proxy.

Additionally fixes a multi interface code-path in which connections
would not time out properly.

This does not fix known bug #39.

URL: http://curl.haxx.se/mail/lib-2013-01/0191.html

lib/url.c

index c107d2c51fb206d8693585e72e14089dd023bd01..8e07a791eabc3f9ff7f5acd4686000e7c28f3148 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -3237,7 +3237,6 @@ CURLcode Curl_protocol_connect(struct connectdata *conn,
                                bool *protocol_done)
 {
   CURLcode result=CURLE_OK;
-  struct SessionHandle *data = conn->data;
 
   *protocol_done = FALSE;
 
@@ -3254,19 +3253,18 @@ CURLcode Curl_protocol_connect(struct connectdata *conn,
     return CURLE_OK;
   }
 
-  Curl_pgrsTime(data, TIMER_CONNECT); /* connect done */
-  Curl_verboseconnect(conn);
-
   if(!conn->bits.protoconnstart) {
 
-    /* Set start time here for timeout purposes in the connect procedure, it
-       is later set again for the progress meter purpose */
-    conn->now = Curl_tvnow();
-
     result = Curl_proxy_connect(conn);
     if(result)
       return result;
 
+    if(conn->bits.tunnel_proxy && conn->bits.httpproxy &&
+       (conn->tunnel_state[FIRSTSOCKET] != TUNNEL_COMPLETE))
+      /* when using an HTTP tunnel proxy, await complete tunnel establishment
+         before proceeding further. Return CURLE_OK so we'll be called again */
+      return CURLE_OK;
+
     if(conn->handler->connect_it) {
       /* is there a protocol-specific connect() procedure? */
 
@@ -5073,6 +5071,10 @@ CURLcode Curl_setup_conn(struct connectdata *conn,
   data->state.crlf_conversions = 0; /* reset CRLF conversion counter */
 #endif /* CURL_DO_LINEEND_CONV */
 
+  /* set start time here for timeout purposes in the connect procedure, it
+     is later set again for the progress meter purpose */
+  conn->now = Curl_tvnow();
+
   for(;;) {
     /* loop for CURL_SERVER_CLOSED_CONNECTION */