2 # -*- coding: iso-8859-1 -*-
6 # same as test_multi2.py, but enforce some debugging and strange API-calls
10 from cStringIO import StringIO
12 from StringIO import StringIO
17 "http://curl.haxx.se",
18 "http://www.python.org",
19 "http://pycurl.sourceforge.net",
20 "http://pycurl.sourceforge.net/THIS_HANDLE_IS_CLOSED",
24 m = pycurl.CurlMulti()
28 # save info in standard Python attributes
35 c.setopt(c.URL, c.url)
36 c.setopt(c.WRITEFUNCTION, c.body.write)
39 # debug - close a handle
46 num_handles = len(m.handles)
49 ret, num_handles = m.perform()
50 if ret != pycurl.E_CALL_MULTI_PERFORM:
52 # currently no more I/O is pending, could do something in the meantime
53 # (display a progress bar, etc.)
58 # save info in standard Python attributes
60 c.http_code = c.getinfo(c.HTTP_CODE)
62 # handle already closed - see debug above
70 # in the C API this is the wrong calling order, but pycurl
71 # handles this automatically
75 # actually, remove_handle is called automatically on close
81 data = c.body.getvalue()
83 print "**********", c.url, "**********"
86 print "%-53s http_code %3d, %6d bytes" % (c.url, c.http_code, len(data))