components/python/pycurl/patches/pycurl-mondo.patch
changeset 5109 5d341c4a6b80
parent 5108 0546c7178c66
child 5110 92c73cda9414
equal deleted inserted replaced
5108:0546c7178c66 5109:5d341c4a6b80
     1 --- setup.py.orig	Fri Aug 07 15:00:51 2009 -0700
       
     2 +++ setup.py	Tue Sep 21 10:59:03 2010 -0700
       
     3 @@ -97,8 +97,7 @@
       
     4          else:
       
     5              extra_compile_args.append(e)
       
     6      libs = split_quoted(
       
     7 -        os.popen("'%s' --libs" % CURL_CONFIG).read()+\
       
     8 -        os.popen("'%s' --static-libs" % CURL_CONFIG).read())
       
     9 +        os.popen("'%s' --libs" % CURL_CONFIG).read())
       
    10      for e in libs:
       
    11          if e[:2] == "-l":
       
    12              libraries.append(e[2:])
       
    13 
       
    14 --- src/pycurl.c.orig	Fri Aug 07 15:00:51 2009 -0700
       
    15 +++ src/pycurl.c	Tue Sep 21 10:59:03 2010 -0700
       
    16 @@ -747,6 +747,59 @@
       
    17      return self;
       
    18  }
       
    19  
       
    20 +/* initializer - used to intialize curl easy handles for use with pycurl */
       
    21 +static int
       
    22 +util_curl_init(CurlObject *self)
       
    23 +{
       
    24 +    int res;
       
    25 +    char *s = NULL;
       
    26 +
       
    27 +    /* Set curl error buffer and zero it */
       
    28 +    res = curl_easy_setopt(self->handle, CURLOPT_ERRORBUFFER, self->error);
       
    29 +    if (res != CURLE_OK) {
       
    30 +        return (-1);
       
    31 +    }
       
    32 +    memset(self->error, 0, sizeof(self->error));
       
    33 +
       
    34 +    /* Set backreference */
       
    35 +    res = curl_easy_setopt(self->handle, CURLOPT_PRIVATE, (char *) self);
       
    36 +    if (res != CURLE_OK) {
       
    37 +        return (-1);
       
    38 +    }
       
    39 +
       
    40 +    /* Enable NOPROGRESS by default, i.e. no progress output */
       
    41 +    res = curl_easy_setopt(self->handle, CURLOPT_NOPROGRESS, (long)1);
       
    42 +    if (res != CURLE_OK) {
       
    43 +        return (-1);
       
    44 +    }
       
    45 +
       
    46 +    /* Disable VERBOSE by default, i.e. no verbose output */
       
    47 +    res = curl_easy_setopt(self->handle, CURLOPT_VERBOSE, (long)0);
       
    48 +    if (res != CURLE_OK) {
       
    49 +        return (-1);
       
    50 +    }
       
    51 +
       
    52 +    /* Set FTP_ACCOUNT to NULL by default */
       
    53 +    res = curl_easy_setopt(self->handle, CURLOPT_FTP_ACCOUNT, NULL);
       
    54 +    if (res != CURLE_OK) {
       
    55 +        return (-1);
       
    56 +    }
       
    57 +
       
    58 +    /* Set default USERAGENT */
       
    59 +    s = (char *) malloc(7 + strlen(LIBCURL_VERSION) + 1);
       
    60 +    if (s == NULL) {
       
    61 +        return (-1);
       
    62 +    }
       
    63 +    strcpy(s, "PycURL/"); strcpy(s+7, LIBCURL_VERSION);
       
    64 +    res = curl_easy_setopt(self->handle, CURLOPT_USERAGENT, (char *) s);
       
    65 +    if (res != CURLE_OK) {
       
    66 +        free(s);
       
    67 +        return (-1);
       
    68 +    }
       
    69 +    self->options[ OPT_INDEX(CURLOPT_USERAGENT) ] = s; s = NULL;
       
    70 +
       
    71 +    return (0);
       
    72 +}
       
    73  
       
    74  /* constructor - this is a module-level function returning a new instance */
       
    75  static CurlObject *
       
    76 @@ -754,7 +807,6 @@
       
    77  {
       
    78      CurlObject *self = NULL;
       
    79      int res;
       
    80 -    char *s = NULL;
       
    81  
       
    82      UNUSED(dummy);
       
    83  
       
    84 @@ -768,44 +820,9 @@
       
    85      if (self->handle == NULL)
       
    86          goto error;
       
    87  
       
    88 -    /* Set curl error buffer and zero it */
       
    89 -    res = curl_easy_setopt(self->handle, CURLOPT_ERRORBUFFER, self->error);
       
    90 -    if (res != CURLE_OK)
       
    91 -        goto error;
       
    92 -    memset(self->error, 0, sizeof(self->error));
       
    93 -
       
    94 -    /* Set backreference */
       
    95 -    res = curl_easy_setopt(self->handle, CURLOPT_PRIVATE, (char *) self);
       
    96 -    if (res != CURLE_OK)
       
    97 -        goto error;
       
    98 -
       
    99 -    /* Enable NOPROGRESS by default, i.e. no progress output */
       
   100 -    res = curl_easy_setopt(self->handle, CURLOPT_NOPROGRESS, (long)1);
       
   101 -    if (res != CURLE_OK)
       
   102 -        goto error;
       
   103 -
       
   104 -    /* Disable VERBOSE by default, i.e. no verbose output */
       
   105 -    res = curl_easy_setopt(self->handle, CURLOPT_VERBOSE, (long)0);
       
   106 -    if (res != CURLE_OK)
       
   107 -        goto error;
       
   108 -
       
   109 -    /* Set FTP_ACCOUNT to NULL by default */
       
   110 -    res = curl_easy_setopt(self->handle, CURLOPT_FTP_ACCOUNT, NULL);
       
   111 -    if (res != CURLE_OK)
       
   112 -        goto error;
       
   113 -
       
   114 -    /* Set default USERAGENT */
       
   115 -    s = (char *) malloc(7 + strlen(LIBCURL_VERSION) + 1);
       
   116 -    if (s == NULL)
       
   117 -        goto error;
       
   118 -    strcpy(s, "PycURL/"); strcpy(s+7, LIBCURL_VERSION);
       
   119 -    res = curl_easy_setopt(self->handle, CURLOPT_USERAGENT, (char *) s);
       
   120 -    if (res != CURLE_OK) {
       
   121 -        free(s);
       
   122 -        goto error;
       
   123 -    }
       
   124 -    self->options[ OPT_INDEX(CURLOPT_USERAGENT) ] = s; s = NULL;
       
   125 -
       
   126 +    res = util_curl_init(self);
       
   127 +    if (res < 0)
       
   128 +            goto error;
       
   129      /* Success - return new object */
       
   130      return self;
       
   131  
       
   132 @@ -1425,6 +1442,7 @@
       
   133  do_curl_reset(CurlObject *self)
       
   134  {
       
   135      unsigned int i;
       
   136 +    int res;
       
   137  
       
   138      curl_easy_reset(self->handle);
       
   139  
       
   140 @@ -1452,7 +1470,17 @@
       
   141          }
       
   142      }
       
   143  
       
   144 +    res = util_curl_init(self);
       
   145 +    if (res < 0)
       
   146 +            goto error;
       
   147 +
       
   148 +    Py_INCREF(Py_None);
       
   149      return Py_None;
       
   150 +
       
   151 +error:
       
   152 +    Py_DECREF(self);    /* this also closes self->handle */
       
   153 +    PyErr_SetString(ErrorObject, "resetting curl failed");
       
   154 +    return NULL;
       
   155  }
       
   156  
       
   157  /* --------------- unsetopt/setopt/getinfo --------------- */
       
   158 @@ -1501,6 +1529,8 @@
       
   159      case CURLOPT_RANDOM_FILE:
       
   160      case CURLOPT_SSL_CIPHER_LIST:
       
   161      case CURLOPT_USERPWD:
       
   162 +    case CURLOPT_PROXYUSERNAME:
       
   163 +    case CURLOPT_PROXYPASSWORD:
       
   164          SETOPT((char *) 0);
       
   165          opt_index = OPT_INDEX(option);
       
   166          break;
       
   167 @@ -1627,6 +1657,9 @@
       
   168          case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5:
       
   169          case CURLOPT_CRLFILE:
       
   170          case CURLOPT_ISSUERCERT:
       
   171 +        case CURLOPT_NOPROXY:
       
   172 +        case CURLOPT_PROXYUSERNAME:
       
   173 +        case CURLOPT_PROXYPASSWORD:
       
   174  /* FIXME: check if more of these options allow binary data */
       
   175              str = PyString_AsString_NoNUL(obj);
       
   176              if (str == NULL)
       
   177 @@ -3561,6 +3594,9 @@
       
   178      insint_c(d, "PROXYTYPE_HTTP", CURLPROXY_HTTP);
       
   179      insint_c(d, "PROXYTYPE_SOCKS4", CURLPROXY_SOCKS4);
       
   180      insint_c(d, "PROXYTYPE_SOCKS5", CURLPROXY_SOCKS5);
       
   181 +    insint_c(d, "PROXYTYPE_HTTP_1_0", CURLPROXY_HTTP_1_0);
       
   182 +    insint_c(d, "PROXYTYPE_SOCKS4A", CURLPROXY_SOCKS4A);
       
   183 +    insint_c(d, "PROXYTYPE_SOCKS5_HOSTNAME", CURLPROXY_SOCKS5_HOSTNAME);
       
   184  
       
   185      /* curl_httpauth: constants for setopt(HTTPAUTH, x) */
       
   186      insint_c(d, "HTTPAUTH_NONE", CURLAUTH_NONE);
       
   187 @@ -3735,6 +3771,9 @@
       
   188      insint_c(d, "CRLFILE", CURLOPT_CRLFILE);
       
   189      insint_c(d, "ISSUERCERT", CURLOPT_ISSUERCERT);
       
   190      insint_c(d, "ADDRESS_SCOPE", CURLOPT_ADDRESS_SCOPE);
       
   191 +    insint_c(d, "NOPROXY", CURLOPT_NOPROXY);
       
   192 +    insint_c(d, "PROXYUSERNAME", CURLOPT_PROXYUSERNAME);
       
   193 +    insint_c(d, "PROXYPASSWORD", CURLOPT_PROXYPASSWORD);
       
   194  
       
   195      insint_c(d, "M_TIMERFUNCTION", CURLMOPT_TIMERFUNCTION);
       
   196      insint_c(d, "M_SOCKETFUNCTION", CURLMOPT_SOCKETFUNCTION);