This file is indexed.

/usr/share/doc/python-pycurl/html/callbacks.html is in python-pycurl 7.19.3-0ubuntu3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>PyCurl: Callbacks</title>
  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
  <meta name="revisit-after" content="30 days" />
  <meta name="robots" content="noarchive, index, follow" />
</head>
<body>

<h1>Callbacks</h1>

<p>For more fine-grained control, libcurl allows a
number of callbacks to be associated with each connection. In
pycurl, callbacks are defined using the <code>setopt()</code> method for
Curl objects with options WRITEFUNCTION, READFUNCTION, HEADERFUNCTION,
PROGRESSFUNCTION, IOCTLFUNCTION, or DEBUGFUNCTION. These options
correspond to the libcurl options with CURLOPT_* prefix removed.  A
callback in pycurl must be either a regular Python function, a class
method or an extension type function.</p>

<p>There are some limitations to some of the options which can be used
concurrently with the pycurl callbacks compared to the libcurl callbacks.
This is to allow different callback functions to be associated with
different Curl objects.  More specifically, WRITEDATA cannot
be used with WRITEFUNCTION, READDATA cannot be used with READFUNCTION,
WRITEHEADER cannot be used with HEADERFUNCTION, PROGRESSDATA cannot be
used with PROGRESSFUNCTION, IOCTLDATA cannot be used with IOCTLFUNCTION,
and DEBUGDATA cannot be used with DEBUGFUNCTION.
In practice, these limitations can be overcome by having a callback
function be a class instance method and rather use the class instance
attributes to store per object data such as files used in the callbacks.
</p>

The signature of each callback used in pycurl is as follows:<br/>
<br/>
<code>WRITEFUNCTION(</code><em>string</em><code>) </code><em>-&gt; number of characters written<br/>
</em>
<br/>
<code>READFUNCTION(</code><em>number of characters to read</em><code>)</code><em>-&gt;
string</em><br/>
<br/>
<code>HEADERFUNCTION(</code><em>string</em><code>)</code><em> -&gt; number of characters written<br/>
</em><br/>
<code>PROGRESSFUNCTION(</code><em>download total, downloaded, upload total, uploaded</em><code>) </code><em>-&gt; status</em><br/>
<br/>
<code>DEBUGFUNCTION(</code><em>debug message type, debug message string</em><code>)</code>
<em>-&gt; None<br/></em>
<br/>
<code>IOCTLFUNCTION(</code><em>ioctl cmd</em><code>)</code>
<em>-&gt; status<br/></em>
<br/>

<p>In addition, <code>READFUNCTION</code> may return
<code>READFUNC_ABORT</code> or <code>READFUNC_PAUSE</code>. See the libcurl
documentation for an explanation of these values.
The <code>WRITEFUNCTION</code> and <code>HEADERFUNCTION</code> callbacks
may return <code>None</code>, which is an alternate way of indicating that
the callback has consumed all of the string passed to it.</p>

<hr/>

<h2>Example: Callbacks for document header and body</h2>

<p>This example prints the header data to stderr and the body data to
stdout.  Also note that neither callback returns the number of bytes
written.  For WRITEFUNCTION and HEADERFUNCTION callbacks, returning
None implies that all bytes where written.</p>

<pre>
    ## Callback function invoked when body data is ready
    def body(buf):
        # Print body data to stdout
        import sys
        sys.stdout.write(buf)
        # Returning None implies that all bytes were written

    ## Callback function invoked when header data is ready
    def header(buf):
        # Print header data to stderr
        import sys
        sys.stderr.write(buf)
        # Returning None implies that all bytes were written

    c = pycurl.Curl()
    c.setopt(pycurl.URL, "http://www.python.org/")
    c.setopt(pycurl.WRITEFUNCTION, body)
    c.setopt(pycurl.HEADERFUNCTION, header)
    c.perform()
</pre>

<h2>Example: Download/upload progress callback</h2>

<p>This example shows how to use the progress callback.  When downloading
a document, the arguments related to uploads are zero, and vice versa.</p>

<pre>
    ## Callback function invoked when download/upload has progress
    def progress(download_t, download_d, upload_t, upload_d):
        print "Total to download", download_t
        print "Total downloaded", download_d
        print "Total to upload", upload_t
        print "Total uploaded", upload_d

    c.setopt(c.URL, "http://slashdot.org/")
    c.setopt(c.NOPROGRESS, 0)
    c.setopt(c.PROGRESSFUNCTION, progress)
    c.perform()
</pre>

<h2>Example: Debug callbacks</h2>

<p>This example shows how to use the debug callback.  The debug message
type is an integer indicating the type of debug message.  The
VERBOSE option must be enabled for this callback to be invoked.</p>

<pre>
    def test(debug_type, debug_msg):
        print "debug(%d): %s" % (debug_type, debug_msg)

    c = pycurl.Curl()
    c.setopt(pycurl.URL, "http://curl.haxx.se/")
    c.setopt(pycurl.VERBOSE, 1)
    c.setopt(pycurl.DEBUGFUNCTION, test)
    c.perform()
</pre>

<h2>Other examples</h2>
<p>The pycurl distribution also contains a number of test scripts and
examples which show how to use the various callbacks in libcurl.
For instance, the file 'examples/file_upload.py' in the distribution contains
example code for using READFUNCTION, 'tests/test_cb.py' shows
WRITEFUNCTION and HEADERFUNCTION, 'tests/test_debug.py' shows DEBUGFUNCTION,
and 'tests/test_getinfo.py' shows PROGRESSFUNCTION.</p>


<hr />
<p>
  <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>
</p>

</body>
</html>