[Python-modules-commits] [pycurl] 86/140: Import pycurl_7.19.0.orig.tar.gz
Barry Warsaw
barry at moszumanska.debian.org
Wed Oct 1 21:45:10 UTC 2014
This is an automated email from the git hooks/post-receive script.
barry pushed a commit to branch master
in repository pycurl.
commit 1beefa196373329e3f3a4d4d19463deed7a855c6
Author: Barry Warsaw <barry at python.org>
Date: Wed Oct 1 16:43:48 2014 -0400
Import pycurl_7.19.0.orig.tar.gz
---
ChangeLog | 20 +++++++-
PKG-INFO | 2 +-
TODO | 13 +----
doc/curlobject.html | 10 +++-
setup.py | 4 +-
setup_win32_ssl.py | 4 +-
src/pycurl.c | 126 ++++++++++++++++++++++++++++++++++++++++++++---
tests/test_socketopen.py | 17 +++++++
8 files changed, 170 insertions(+), 26 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8df1dbe..0fb7f8c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,22 @@
-Version 7.18.2 [requires libcurl-7.18.2 or better]
+Version 7.19.0 [requires libcurl-7.19.0 or better]
+--------------
+
+ * Added CURLFILE, ADDRESS_SCOPE and ISSUERCERT options,
+ as well as the APPCONNECT_TIME info.
+
+ * Added PRIMARY_IP info (patch by
+ Yuhui H <eyecat at gmail.com>).
+
+ * Added support for curl_easy_reset through a
+ new 'reset' method on curl objects
+ (patch by Nick Pilon <npilon at oreilly.com>).
+
+ * Added support for OPENSOCKET callbacks.
+ See 'tests/test_opensocket.py' for example
+ usage (patch by Thomas Hunger <teh at camvine.com>).
+
+
+Version 7.18.2
--------------
* Added REDIRECT_URL info and M_MAXCONNECTS option
diff --git a/PKG-INFO b/PKG-INFO
index 0d56b89..db5b31b 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: pycurl
-Version: 7.18.2
+Version: 7.19.0
Summary: PycURL -- cURL library module for Python
Home-page: http://pycurl.sourceforge.net/
Author: Kjetil Jacobsen, Markus F.X.J. Oberhumer
diff --git a/TODO b/TODO
index 24b95ee..54d1da7 100644
--- a/TODO
+++ b/TODO
@@ -1,23 +1,12 @@
-# $Id: TODO,v 1.99 2008/04/22 13:47:15 kjetilja Exp $
-# vi:ts=4:et
-
If you want to hack on pycurl, here's our list of unresolved issues:
NEW FEATURES/IMPROVEMENTS:
- * Callback handling for opening socket and stream seek.
+ * Callback handling for stream seek.
* Add docs to the high-level interface.
- * Add more options to the undocumented and currently mostly useless
- Curl.unsetopt() method. Have to carefully check the libcurl source
- code for each option we want to support.
-
- * curl_easy_reset() should probably be supported. But we have to be
- careful since curl_easy_reset() e.g. modifies callbacks and other
- pointers which could leave pycurl and libcurl out of sync.
-
DEFICIENICES:
diff --git a/doc/curlobject.html b/doc/curlobject.html
index 4a6fe78..a21bde2 100644
--- a/doc/curlobject.html
+++ b/doc/curlobject.html
@@ -29,6 +29,14 @@ any references to it, but can also be called explicitly.</p>
<a href="http://curl.haxx.se/libcurl/c/curl_easy_perform.html"><code>curl_easy_perform</code></a> in libcurl.</p>
</dd>
+<dt><code>reset()</code> -> <em>None</em></dt>
+<dd>
+<p>Corresponds to
+<a
+href="http://curl.haxx.se/libcurl/c/curl_easy_reset.html"><code>curl_easy_reset</code></a> in libcurl.</p>
+</dd>
+
+
<dt><code>setopt(</code><em>option, value</em><code>)</code> -> <em>None</em></dt>
<dd>
@@ -95,7 +103,7 @@ print c.getinfo(pycurl.HTTP_CODE), c.getinfo(pycurl.EFFECTIVE_URL)
<a href="http://validator.w3.org/check/referer"><img align="right"
src="http://www.w3.org/Icons/valid-xhtml10"
alt="Valid XHTML 1.0!" height="31" width="88" border="0" /></a>
- $Id: curlobject.html,v 1.14 2005/02/11 11:09:09 mfx Exp $
+ $Id: curlobject.html,v 1.15 2008/08/05 20:51:13 kjetilja Exp $
</p>
</body>
diff --git a/setup.py b/setup.py
index 928ce10..0ffd9d2 100644
--- a/setup.py
+++ b/setup.py
@@ -1,13 +1,13 @@
#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
# vi:ts=4:et
-# $Id: setup.py,v 1.149 2008/06/12 18:01:53 kjetilja Exp $
+# $Id: setup.py,v 1.150 2008/09/09 17:40:34 kjetilja Exp $
"""Setup script for the PycURL module distribution."""
PACKAGE = "pycurl"
PY_PACKAGE = "curl"
-VERSION = "7.18.2"
+VERSION = "7.19.0"
import glob, os, re, sys, string
import distutils
diff --git a/setup_win32_ssl.py b/setup_win32_ssl.py
index 2299e99..76412e2 100644
--- a/setup_win32_ssl.py
+++ b/setup_win32_ssl.py
@@ -1,13 +1,13 @@
#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
# vi:ts=4:et
-# $Id: setup_win32_ssl.py,v 1.44 2008/06/12 18:01:53 kjetilja Exp $
+# $Id: setup_win32_ssl.py,v 1.45 2008/09/09 17:40:34 kjetilja Exp $
import os, sys, string
assert sys.platform == "win32", "Only for building on Win32 with SSL and zlib"
-CURL_DIR = r"c:\src\build\pycurl\curl-7.18.2-ssl"
+CURL_DIR = r"c:\src\build\pycurl\curl-7.19.0-ssl"
OPENSSL_DIR = r"c:\src\build\pycurl\openssl-0.9.7g"
sys.argv.insert(1, "--curl-dir=" + CURL_DIR)
diff --git a/src/pycurl.c b/src/pycurl.c
index 1204ab5..a17a23b 100644
--- a/src/pycurl.c
+++ b/src/pycurl.c
@@ -1,4 +1,4 @@
-/* $Id: pycurl.c,v 1.143 2008/06/12 18:01:53 kjetilja Exp $ */
+/* $Id: pycurl.c,v 1.147 2008/09/09 17:40:34 kjetilja Exp $ */
/* PycURL -- cURL Python module
*
@@ -27,6 +27,8 @@
* Daniel Pena Arteaga <dpena at ph.tum.de>
* Jim Patterson
* Yuhui H <eyecat at gmail.com>
+ * Nick Pilon <npilon at oreilly.com>
+ * Thomas Hunger <teh at camvine.org>
*
* See file README for license information.
*/
@@ -55,8 +57,8 @@
#if !defined(PY_VERSION_HEX) || (PY_VERSION_HEX < 0x02020000)
# error "Need Python version 2.2 or greater to compile pycurl."
#endif
-#if !defined(LIBCURL_VERSION_NUM) || (LIBCURL_VERSION_NUM < 0x071202)
-# error "Need libcurl version 7.18.2 or greater to compile pycurl."
+#if !defined(LIBCURL_VERSION_NUM) || (LIBCURL_VERSION_NUM < 0x071300)
+# error "Need libcurl version 7.19.0 or greater to compile pycurl."
#endif
/* Python < 2.5 compat for Py_ssize_t */
@@ -69,10 +71,6 @@ typedef int Py_ssize_t;
#undef UNUSED
#define UNUSED(var) ((void)&var)
-#undef COMPILE_TIME_ASSERT
-#define COMPILE_TIME_ASSERT(expr) \
- { typedef int compile_time_assert_fail__[1 - 2 * !(expr)]; }
-
/* Cruft for thread safe SSL crypto locks, snapped from the PHP curl extension */
#if defined(HAVE_CURL_SSL)
# if defined(HAVE_CURL_OPENSSL)
@@ -157,6 +155,7 @@ typedef struct {
PyObject *pro_cb;
PyObject *debug_cb;
PyObject *ioctl_cb;
+ PyObject *opensocket_cb;
/* file objects */
PyObject *readdata_fp;
PyObject *writedata_fp;
@@ -734,6 +733,7 @@ util_curl_new(void)
self->pro_cb = NULL;
self->debug_cb = NULL;
self->ioctl_cb = NULL;
+ self->opensocket_cb = NULL;
/* Set file object pointers to NULL by default */
self->readdata_fp = NULL;
@@ -1128,6 +1128,62 @@ header_callback(char *ptr, size_t size, size_t nmemb, void *stream)
return util_write_callback(1, ptr, size, nmemb, stream);
}
+/* curl_socket_t is just an int on unix/windows (with limitations that
+ * are not important here) */
+static curl_socket_t
+opensocket_callback(void *clientp, curlsocktype purpose,
+ struct curl_sockaddr *address)
+{
+ PyObject *arglist;
+ PyObject *result = NULL;
+ PyObject *fileno_result = NULL;
+ CurlObject *self;
+ PyThreadState *tmp_state;
+ int ret = CURL_SOCKET_BAD;
+
+ self = (CurlObject *)clientp;
+ tmp_state = get_thread_state(self);
+
+ PyEval_AcquireThread(tmp_state);
+ arglist = Py_BuildValue("(iii)", address->family, address->socktype, address->protocol);
+ if (arglist == NULL)
+ goto verbose_error;
+
+ result = PyEval_CallObject(self->opensocket_cb, arglist);
+
+ Py_DECREF(arglist);
+ if (result == NULL) {
+ goto verbose_error;
+ }
+
+ if (PyObject_HasAttrString(result, "fileno")) {
+ fileno_result = PyObject_CallMethod(result, "fileno", NULL);
+
+ if (fileno_result == NULL) {
+ ret = CURL_SOCKET_BAD;
+ goto verbose_error;
+ }
+ // normal operation:
+ if (PyInt_Check(fileno_result)) {
+ ret = dup(PyInt_AsLong(fileno_result));
+ goto done;
+ }
+ } else {
+ PyErr_SetString(ErrorObject, "Return value must be a socket.");
+ ret = CURL_SOCKET_BAD;
+ goto verbose_error;
+ }
+
+silent_error:
+done:
+ Py_XDECREF(result);
+ Py_XDECREF(fileno_result);
+ PyEval_ReleaseThread(tmp_state);
+ return ret;
+verbose_error:
+ PyErr_Print();
+ goto silent_error;
+}
static size_t
read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
@@ -1363,6 +1419,42 @@ verbose_error:
}
+/* ------------------------ reset ------------------------ */
+
+static PyObject*
+do_curl_reset(CurlObject *self)
+{
+ unsigned int i;
+
+ curl_easy_reset(self->handle);
+
+ /* Decref callbacks and file handles */
+ util_curl_xdecref(self, 4 | 8, self->handle);
+
+ /* Free all variables allocated by setopt */
+#undef SFREE
+#define SFREE(v) if ((v) != NULL) (curl_formfree(v), (v) = NULL)
+ SFREE(self->httppost);
+#undef SFREE
+#define SFREE(v) if ((v) != NULL) (curl_slist_free_all(v), (v) = NULL)
+ SFREE(self->httpheader);
+ SFREE(self->http200aliases);
+ SFREE(self->quote);
+ SFREE(self->postquote);
+ SFREE(self->prequote);
+#undef SFREE
+
+ /* Last, free the options */
+ for (i = 0; i < OPTIONS_SIZE; i++) {
+ if (self->options[i] != NULL) {
+ free(self->options[i]);
+ self->options[i] = NULL;
+ }
+ }
+
+ return Py_None;
+}
+
/* --------------- unsetopt/setopt/getinfo --------------- */
static PyObject *
@@ -1533,6 +1625,8 @@ do_curl_setopt(CurlObject *self, PyObject *args)
case CURLOPT_SSH_PRIVATE_KEYFILE:
case CURLOPT_COPYPOSTFIELDS:
case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5:
+ case CURLOPT_CRLFILE:
+ case CURLOPT_ISSUERCERT:
/* FIXME: check if more of these options allow binary data */
str = PyString_AsString_NoNUL(obj);
if (str == NULL)
@@ -1923,6 +2017,7 @@ do_curl_setopt(CurlObject *self, PyObject *args)
const curl_progress_callback pro_cb = progress_callback;
const curl_debug_callback debug_cb = debug_callback;
const curl_ioctl_callback ioctl_cb = ioctl_callback;
+ const curl_opensocket_callback opensocket_cb = opensocket_callback;
switch(option) {
case CURLOPT_WRITEFUNCTION:
@@ -1973,6 +2068,13 @@ do_curl_setopt(CurlObject *self, PyObject *args)
curl_easy_setopt(self->handle, CURLOPT_IOCTLFUNCTION, ioctl_cb);
curl_easy_setopt(self->handle, CURLOPT_IOCTLDATA, self);
break;
+ case CURLOPT_OPENSOCKETFUNCTION:
+ Py_INCREF(obj);
+ ZAP(self->opensocket_cb);
+ self->opensocket_cb = obj;
+ curl_easy_setopt(self->handle, CURLOPT_OPENSOCKETFUNCTION, opensocket_cb);
+ curl_easy_setopt(self->handle, CURLOPT_OPENSOCKETDATA, self);
+ break;
default:
/* None of the function options were recognized, throw exception */
@@ -2071,6 +2173,7 @@ do_curl_getinfo(CurlObject *self, PyObject *args)
case CURLINFO_EFFECTIVE_URL:
case CURLINFO_FTP_ENTRY_PATH:
case CURLINFO_REDIRECT_URL:
+ case CURLINFO_PRIMARY_IP:
{
/* Return PyString as result */
char *s_res = NULL;
@@ -2088,6 +2191,7 @@ do_curl_getinfo(CurlObject *self, PyObject *args)
}
case CURLINFO_CONNECT_TIME:
+ case CURLINFO_APPCONNECT_TIME:
case CURLINFO_CONTENT_LENGTH_DOWNLOAD:
case CURLINFO_CONTENT_LENGTH_UPLOAD:
case CURLINFO_NAMELOOKUP_TIME:
@@ -2841,6 +2945,7 @@ static char co_getinfo_doc [] = "getinfo(info) -> Res. Extract and return infor
static char co_perform_doc [] = "perform() -> None. Perform a file transfer. Throws pycurl.error exception upon failure.\n";
static char co_setopt_doc [] = "setopt(option, parameter) -> None. Set curl session option. Throws pycurl.error exception upon failure.\n";
static char co_unsetopt_doc [] = "unsetopt(option) -> None. Reset curl session option to default value. Throws pycurl.error exception upon failure.\n";
+static char co_reset_doc [] = "reset() -> None. Reset all options set on curl handle to default values, but preserves live connections, session ID cache, DNS cache, cookies, and shares.\n";
static char co_multi_fdset_doc [] = "fdset() -> Tuple. Returns a tuple of three lists that can be passed to the select.select() method .\n";
static char co_multi_info_read_doc [] = "info_read([max_objects]) -> Tuple. Returns a tuple (number of queued handles, [curl objects]).\n";
@@ -2860,6 +2965,7 @@ static PyMethodDef curlobject_methods[] = {
{"perform", (PyCFunction)do_curl_perform, METH_NOARGS, co_perform_doc},
{"setopt", (PyCFunction)do_curl_setopt, METH_VARARGS, co_setopt_doc},
{"unsetopt", (PyCFunction)do_curl_unsetopt, METH_VARARGS, co_unsetopt_doc},
+ {"reset", (PyCFunction)do_curl_reset, METH_NOARGS, co_reset_doc},
{NULL, NULL, 0, NULL}
};
@@ -3598,6 +3704,7 @@ initpycurl(void)
insint_c(d, "FTPSSLAUTH", CURLOPT_FTPSSLAUTH);
insint_c(d, "IOCTLFUNCTION", CURLOPT_IOCTLFUNCTION);
insint_c(d, "IOCTLDATA", CURLOPT_IOCTLDATA);
+ insint_c(d, "OPENSOCKETFUNCTION", CURLOPT_OPENSOCKETFUNCTION);
insint_c(d, "FTP_ACCOUNT", CURLOPT_FTP_ACCOUNT);
insint_c(d, "IGNORE_CONTENT_LENGTH", CURLOPT_IGNORE_CONTENT_LENGTH);
insint_c(d, "COOKIELIST", CURLOPT_COOKIELIST);
@@ -3625,6 +3732,9 @@ initpycurl(void)
insint_c(d, "COPYPOSTFIELDS", CURLOPT_COPYPOSTFIELDS);
insint_c(d, "SSH_HOST_PUBLIC_KEY_MD5", CURLOPT_SSH_HOST_PUBLIC_KEY_MD5);
insint_c(d, "AUTOREFERER", CURLOPT_AUTOREFERER);
+ insint_c(d, "CRLFILE", CURLOPT_CRLFILE);
+ insint_c(d, "ISSUERCERT", CURLOPT_ISSUERCERT);
+ insint_c(d, "ADDRESS_SCOPE", CURLOPT_ADDRESS_SCOPE);
insint_c(d, "M_TIMERFUNCTION", CURLMOPT_TIMERFUNCTION);
insint_c(d, "M_SOCKETFUNCTION", CURLMOPT_SOCKETFUNCTION);
@@ -3675,6 +3785,7 @@ initpycurl(void)
insint_c(d, "TOTAL_TIME", CURLINFO_TOTAL_TIME);
insint_c(d, "NAMELOOKUP_TIME", CURLINFO_NAMELOOKUP_TIME);
insint_c(d, "CONNECT_TIME", CURLINFO_CONNECT_TIME);
+ insint_c(d, "APPCONNECT_TIME", CURLINFO_APPCONNECT_TIME);
insint_c(d, "PRETRANSFER_TIME", CURLINFO_PRETRANSFER_TIME);
insint_c(d, "SIZE_UPLOAD", CURLINFO_SIZE_UPLOAD);
insint_c(d, "SIZE_DOWNLOAD", CURLINFO_SIZE_DOWNLOAD);
@@ -3691,6 +3802,7 @@ initpycurl(void)
insint_c(d, "REDIRECT_TIME", CURLINFO_REDIRECT_TIME);
insint_c(d, "REDIRECT_COUNT", CURLINFO_REDIRECT_COUNT);
insint_c(d, "REDIRECT_URL", CURLINFO_REDIRECT_URL);
+ insint_c(d, "PRIMARY_IP", CURLINFO_PRIMARY_IP);
insint_c(d, "HTTP_CONNECTCODE", CURLINFO_HTTP_CONNECTCODE);
insint_c(d, "HTTPAUTH_AVAIL", CURLINFO_HTTPAUTH_AVAIL);
insint_c(d, "PROXYAUTH_AVAIL", CURLINFO_PROXYAUTH_AVAIL);
diff --git a/tests/test_socketopen.py b/tests/test_socketopen.py
new file mode 100644
index 0000000..d3f0a62
--- /dev/null
+++ b/tests/test_socketopen.py
@@ -0,0 +1,17 @@
+import pycurl
+import StringIO
+import socket
+
+def socketopen(family, socktype, protocol):
+ print family, socktype, protocol
+ s = socket.socket(family, socktype, protocol)
+ s.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
+ return s
+
+sio = StringIO.StringIO()
+
+c = pycurl.Curl()
+c.setopt(pycurl.OPENSOCKETFUNCTION, socketopen)
+c.setopt(pycurl.URL, 'http://camvine.com')
+c.setopt(pycurl.WRITEFUNCTION, sio.write)
+c.perform()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pycurl.git
More information about the Python-modules-commits
mailing list