--- setup.py.orig Fri Aug 07 15:00:51 2009 -0700
+++ setup.py Tue Sep 21 10:59:03 2010 -0700
@@ -97,8 +97,7 @@
else:
extra_compile_args.append(e)
libs = split_quoted(
- os.popen("'%s' --libs" % CURL_CONFIG).read()+\
- os.popen("'%s' --static-libs" % CURL_CONFIG).read())
+ os.popen("'%s' --libs" % CURL_CONFIG).read())
for e in libs:
if e[:2] == "-l":
libraries.append(e[2:])
--- src/pycurl.c.orig Fri Aug 07 15:00:51 2009 -0700
+++ src/pycurl.c Tue Sep 21 10:59:03 2010 -0700
@@ -747,6 +747,59 @@
return self;
}
+/* initializer - used to intialize curl easy handles for use with pycurl */
+static int
+util_curl_init(CurlObject *self)
+{
+ int res;
+ char *s = NULL;
+
+ /* Set curl error buffer and zero it */
+ res = curl_easy_setopt(self->handle, CURLOPT_ERRORBUFFER, self->error);
+ if (res != CURLE_OK) {
+ return (-1);
+ }
+ memset(self->error, 0, sizeof(self->error));
+
+ /* Set backreference */
+ res = curl_easy_setopt(self->handle, CURLOPT_PRIVATE, (char *) self);
+ if (res != CURLE_OK) {
+ return (-1);
+ }
+
+ /* Enable NOPROGRESS by default, i.e. no progress output */
+ res = curl_easy_setopt(self->handle, CURLOPT_NOPROGRESS, (long)1);
+ if (res != CURLE_OK) {
+ return (-1);
+ }
+
+ /* Disable VERBOSE by default, i.e. no verbose output */
+ res = curl_easy_setopt(self->handle, CURLOPT_VERBOSE, (long)0);
+ if (res != CURLE_OK) {
+ return (-1);
+ }
+
+ /* Set FTP_ACCOUNT to NULL by default */
+ res = curl_easy_setopt(self->handle, CURLOPT_FTP_ACCOUNT, NULL);
+ if (res != CURLE_OK) {
+ return (-1);
+ }
+
+ /* Set default USERAGENT */
+ s = (char *) malloc(7 + strlen(LIBCURL_VERSION) + 1);
+ if (s == NULL) {
+ return (-1);
+ }
+ strcpy(s, "PycURL/"); strcpy(s+7, LIBCURL_VERSION);
+ res = curl_easy_setopt(self->handle, CURLOPT_USERAGENT, (char *) s);
+ if (res != CURLE_OK) {
+ free(s);
+ return (-1);
+ }
+ self->options[ OPT_INDEX(CURLOPT_USERAGENT) ] = s; s = NULL;
+
+ return (0);
+}
/* constructor - this is a module-level function returning a new instance */
static CurlObject *
@@ -754,7 +807,6 @@
{
CurlObject *self = NULL;
int res;
- char *s = NULL;
UNUSED(dummy);
@@ -768,44 +820,9 @@
if (self->handle == NULL)
goto error;
- /* Set curl error buffer and zero it */
- res = curl_easy_setopt(self->handle, CURLOPT_ERRORBUFFER, self->error);
- if (res != CURLE_OK)
- goto error;
- memset(self->error, 0, sizeof(self->error));
-
- /* Set backreference */
- res = curl_easy_setopt(self->handle, CURLOPT_PRIVATE, (char *) self);
- if (res != CURLE_OK)
- goto error;
-
- /* Enable NOPROGRESS by default, i.e. no progress output */
- res = curl_easy_setopt(self->handle, CURLOPT_NOPROGRESS, (long)1);
- if (res != CURLE_OK)
- goto error;
-
- /* Disable VERBOSE by default, i.e. no verbose output */
- res = curl_easy_setopt(self->handle, CURLOPT_VERBOSE, (long)0);
- if (res != CURLE_OK)
- goto error;
-
- /* Set FTP_ACCOUNT to NULL by default */
- res = curl_easy_setopt(self->handle, CURLOPT_FTP_ACCOUNT, NULL);
- if (res != CURLE_OK)
- goto error;
-
- /* Set default USERAGENT */
- s = (char *) malloc(7 + strlen(LIBCURL_VERSION) + 1);
- if (s == NULL)
- goto error;
- strcpy(s, "PycURL/"); strcpy(s+7, LIBCURL_VERSION);
- res = curl_easy_setopt(self->handle, CURLOPT_USERAGENT, (char *) s);
- if (res != CURLE_OK) {
- free(s);
- goto error;
- }
- self->options[ OPT_INDEX(CURLOPT_USERAGENT) ] = s; s = NULL;
-
+ res = util_curl_init(self);
+ if (res < 0)
+ goto error;
/* Success - return new object */
return self;
@@ -1425,6 +1442,7 @@
do_curl_reset(CurlObject *self)
{
unsigned int i;
+ int res;
curl_easy_reset(self->handle);
@@ -1452,7 +1470,17 @@
}
}
+ res = util_curl_init(self);
+ if (res < 0)
+ goto error;
+
+ Py_INCREF(Py_None);
return Py_None;
+
+error:
+ Py_DECREF(self); /* this also closes self->handle */
+ PyErr_SetString(ErrorObject, "resetting curl failed");
+ return NULL;
}
/* --------------- unsetopt/setopt/getinfo --------------- */
@@ -1501,6 +1529,8 @@
case CURLOPT_RANDOM_FILE:
case CURLOPT_SSL_CIPHER_LIST:
case CURLOPT_USERPWD:
+ case CURLOPT_PROXYUSERNAME:
+ case CURLOPT_PROXYPASSWORD:
SETOPT((char *) 0);
opt_index = OPT_INDEX(option);
break;
@@ -1627,6 +1657,9 @@
case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5:
case CURLOPT_CRLFILE:
case CURLOPT_ISSUERCERT:
+ case CURLOPT_NOPROXY:
+ case CURLOPT_PROXYUSERNAME:
+ case CURLOPT_PROXYPASSWORD:
/* FIXME: check if more of these options allow binary data */
str = PyString_AsString_NoNUL(obj);
if (str == NULL)
@@ -3561,6 +3594,9 @@
insint_c(d, "PROXYTYPE_HTTP", CURLPROXY_HTTP);
insint_c(d, "PROXYTYPE_SOCKS4", CURLPROXY_SOCKS4);
insint_c(d, "PROXYTYPE_SOCKS5", CURLPROXY_SOCKS5);
+ insint_c(d, "PROXYTYPE_HTTP_1_0", CURLPROXY_HTTP_1_0);
+ insint_c(d, "PROXYTYPE_SOCKS4A", CURLPROXY_SOCKS4A);
+ insint_c(d, "PROXYTYPE_SOCKS5_HOSTNAME", CURLPROXY_SOCKS5_HOSTNAME);
/* curl_httpauth: constants for setopt(HTTPAUTH, x) */
insint_c(d, "HTTPAUTH_NONE", CURLAUTH_NONE);
@@ -3735,6 +3771,9 @@
insint_c(d, "CRLFILE", CURLOPT_CRLFILE);
insint_c(d, "ISSUERCERT", CURLOPT_ISSUERCERT);
insint_c(d, "ADDRESS_SCOPE", CURLOPT_ADDRESS_SCOPE);
+ insint_c(d, "NOPROXY", CURLOPT_NOPROXY);
+ insint_c(d, "PROXYUSERNAME", CURLOPT_PROXYUSERNAME);
+ insint_c(d, "PROXYPASSWORD", CURLOPT_PROXYPASSWORD);
insint_c(d, "M_TIMERFUNCTION", CURLMOPT_TIMERFUNCTION);
insint_c(d, "M_SOCKETFUNCTION", CURLMOPT_SOCKETFUNCTION);