|
|
fcfddd |
From ca4705dab05371c40f398b97277024332ed44651 Mon Sep 17 00:00:00 2001
|
|
|
fcfddd |
From: Kamil Dudka <kdudka@redhat.com>
|
|
|
fcfddd |
Date: Tue, 26 Feb 2013 16:58:55 +0100
|
|
|
fcfddd |
Subject: [PATCH 3/4] pycurl.c: allow to return -1 from write callback
|
|
|
fcfddd |
|
|
|
fcfddd |
... to abort the transfer and WRITEFUNC_PAUSE to pause the transfer
|
|
|
fcfddd |
|
|
|
fcfddd |
Reported By: Zdenek Pavlas
|
|
|
fcfddd |
Bug: https://bugzilla.redhat.com/857875
|
|
|
fcfddd |
---
|
|
|
fcfddd |
src/pycurl.c | 11 +++++------
|
|
|
fcfddd |
1 files changed, 5 insertions(+), 6 deletions(-)
|
|
|
fcfddd |
|
|
|
fcfddd |
diff --git a/src/pycurl.c b/src/pycurl.c
|
|
|
fcfddd |
index f197145..b59eeb8 100644
|
|
|
fcfddd |
--- a/src/pycurl.c
|
|
|
fcfddd |
+++ b/src/pycurl.c
|
|
|
fcfddd |
@@ -1081,12 +1081,8 @@ util_write_callback(int flags, char *ptr, size_t size, size_t nmemb, void *strea
|
|
|
fcfddd |
ret = total_size; /* None means success */
|
|
|
fcfddd |
}
|
|
|
fcfddd |
else if (PyInt_Check(result) || PyLong_Check(result)) {
|
|
|
fcfddd |
- long obj_size = PyLong_AsLong(result);
|
|
|
fcfddd |
- if (obj_size < 0 || obj_size > total_size) {
|
|
|
fcfddd |
- PyErr_Format(ErrorObject, "invalid return value for write callback %ld %ld", (long)obj_size, (long)total_size);
|
|
|
fcfddd |
- goto verbose_error;
|
|
|
fcfddd |
- }
|
|
|
fcfddd |
- ret = (size_t) obj_size; /* success */
|
|
|
fcfddd |
+ /* if the cast to long fails, PyLong_AsLong() returns -1L */
|
|
|
fcfddd |
+ ret = (size_t) PyLong_AsLong(result);
|
|
|
fcfddd |
}
|
|
|
fcfddd |
else {
|
|
|
fcfddd |
PyErr_SetString(ErrorObject, "write callback must return int or None");
|
|
|
fcfddd |
@@ -3423,6 +3419,9 @@ initpycurl(void)
|
|
|
fcfddd |
/* Abort curl_read_callback(). */
|
|
|
fcfddd |
insint_c(d, "READFUNC_ABORT", CURL_READFUNC_ABORT);
|
|
|
fcfddd |
|
|
|
fcfddd |
+ /* Pause curl_write_callback(). */
|
|
|
fcfddd |
+ insint_c(d, "WRITEFUNC_PAUSE", CURL_WRITEFUNC_PAUSE);
|
|
|
fcfddd |
+
|
|
|
fcfddd |
/* constants for ioctl callback return values */
|
|
|
fcfddd |
insint_c(d, "IOE_OK", CURLIOE_OK);
|
|
|
fcfddd |
insint_c(d, "IOE_UNKNOWNCMD", CURLIOE_UNKNOWNCMD);
|
|
|
fcfddd |
--
|
|
|
fcfddd |
1.7.1
|
|
|
fcfddd |
|