~ubuntu-branches/ubuntu/saucy/curl/saucy-proposed

« back to all changes in this revision

Viewing changes to lib/http_proxy.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2013-02-12 08:54:32 UTC
  • mfrom: (3.4.34 sid)
  • Revision ID: package-import@ubuntu.com-20130212085432-r1fyi0b37enr93pp
Tags: 7.29.0-1ubuntu1
* Resynchronise with Debian. Remaining changes:
  - Drop dependencies not in main:
    + Build-Depends: Drop stunnel4 and libssh2-1-dev.
    + Drop libssh2-1-dev from binary package Depends.
  - Add new libcurl3-udeb package.
  - Add new curl-udeb package.
* Add warning to debian/patches/series.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
 * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
9
9
 *
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
20
20
 *
21
21
 ***************************************************************************/
22
22
 
23
 
#include "setup.h"
 
23
#include "curl_setup.h"
24
24
 
25
25
#if !defined(CURL_DISABLE_PROXY) && !defined(CURL_DISABLE_HTTP)
26
26
 
27
 
#ifdef HAVE_UNISTD_H
28
 
#include <unistd.h>
29
 
#endif
30
 
 
31
27
#include "urldata.h"
32
28
#include <curl/curl.h>
33
29
#include "http_proxy.h"
45
41
 
46
42
#include "curlx.h"
47
43
 
 
44
#include "curl_memory.h"
48
45
/* The last #include file should be: */
49
46
#include "memdebug.h"
50
47
 
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.
93
 
 *
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.
98
 
 *
99
 
 * This function is BLOCKING which is nasty for all multi interface using apps.
100
90
 */
101
91
 
102
92
CURLcode Curl_proxyCONNECT(struct connectdata *conn,
233
223
        return result;
234
224
 
235
225
      conn->tunnel_state[sockindex] = TUNNEL_CONNECT;
 
226
 
 
227
      /* now we've issued the CONNECT and we're waiting to hear back, return
 
228
         and get called again polling-style */
 
229
      return CURLE_OK;
 
230
 
236
231
    } /* END CONNECT PHASE */
237
232
 
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. */
241
 
 
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 */
245
 
    if(check <= 0) {
246
 
      failf(data, "Proxy CONNECT aborted due to timeout");
247
 
      return CURLE_RECV_ERROR;
248
 
    }
249
 
 
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 */
254
 
        return CURLE_OK;
255
 
      else {
256
 
        DEBUGF(infof(data,
257
 
                     "Multi mode finished polling for response from "
258
 
                     "proxy CONNECT\n"));
259
 
      }
260
 
    }
261
 
    else {
262
 
      DEBUGF(infof(data, "Easy mode waiting response from proxy CONNECT\n"));
263
 
    }
264
 
 
265
 
    /* at this point, either:
266
 
       1) we're in easy-mode and so it's okay to block waiting for a CONNECT
267
 
       response
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. */
271
 
 
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;
577
538
 
 
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;
 
543
    }
 
544
 
578
545
    /* to back to init state */
579
546
    conn->tunnel_state[sockindex] = TUNNEL_INIT;
580
547