Reputation:
in C do return -1 when i want to cancel the download in either the header or the write function. In pycurl i get this error
pycurl.error: invalid return value for write callback -1 17
I dont know what the 17 means but what am i not doing correctly?
Upvotes: 2
Views: 1408
Reputation:
import pycurl
import StringIO
c = pycurl.Curl()
s = StringIO.StringIO()
c.setopt(pycurl.URL, url)
c.setopt(pycurl.HEADER, True)
c.setopt(pycurl.NOBODY, True)
c.setopt(pycurl.WRITEFUNCTION, s.write)
c.perform()
print(s.getvalue())
Upvotes: 1
Reputation: 6160
from pycurl.c:
else if (PyInt_Check(result)) {
long obj_size = PyInt_AsLong(result);
if (obj_size < 0 || obj_size > total_size) {
PyErr_Format(ErrorObject, "invalid return value for write callback %ld %ld", (long)obj_size, (long)total_size);
goto verbose_error;
}
this would mean 17 is the total_size - is this possible ? and -1 (result) is what your callback is returning.
Upvotes: 3