Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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())
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top