4a6fe78716b7e8e37c00f4d7e5155374db668f2b
[plcapi.git] / pycurl / doc / curlobject.html
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml">
5 <head>
6   <title>PycURL: Curl Objects</title>
7   <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
8   <meta name="revisit-after" content="30 days" />
9   <meta name="robots" content="noarchive, index, follow" />
10 </head>
11 <body>
12
13 <h1>Curl Object</h1>
14
15 <p>Curl objects have the following methods:</p>
16
17 <dl>
18 <dt><code>close()</code> -&gt; <em>None</em></dt>
19 <dd>
20 <p>Corresponds to
21 <a href="http://curl.haxx.se/libcurl/c/curl_easy_cleanup.html"><code>curl_easy_cleanup</code></a> in libcurl.
22 This method is automatically called by pycurl when a Curl object no longer has
23 any references to it, but can also be called explicitly.</p>
24 </dd>
25
26 <dt><code>perform()</code> -&gt; <em>None</em></dt>
27 <dd>
28 <p>Corresponds to
29 <a href="http://curl.haxx.se/libcurl/c/curl_easy_perform.html"><code>curl_easy_perform</code></a> in libcurl.</p>
30 </dd>
31
32 <dt><code>setopt(</code><em>option, value</em><code>)</code> -&gt; <em>None</em></dt>
33 <dd>
34
35 <p>Corresponds to
36 <a href="http://curl.haxx.se/libcurl/c/curl_easy_setopt.html"><code>curl_easy_setopt</code></a> in libcurl, where
37 <em>option</em> is specified with the CURLOPT_* constants in libcurl,
38 except that the CURLOPT_ prefix has been removed. The type for
39 <em>value</em> depends on the option, and can be either a string,
40 integer, long integer, file objects, lists, or functions.</p>
41
42 <p>Example usage:</p>
43
44 <pre>
45 import pycurl
46 c = pycurl.Curl()
47 c.setopt(pycurl.URL, "http://www.python.org/")
48 c.setopt(pycurl.HTTPHEADER, ["Accept:"])
49 import StringIO
50 b = StringIO.StringIO()
51 c.setopt(pycurl.WRITEFUNCTION, b.write)
52 c.setopt(pycurl.FOLLOWLOCATION, 1)
53 c.setopt(pycurl.MAXREDIRS, 5)
54 c.perform()
55 print b.getvalue()
56 ...
57 </pre>
58 </dd>
59
60 <dt><code>getinfo(</code><em>option</em><code>) </code>-&gt; <em>Result</em></dt>
61 <dd>
62
63 <p>Corresponds to
64 <a href="http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html"><code>curl_easy_getinfo</code></a> in libcurl, where
65 <em>option</em> is the same as the CURLINFO_* constants in libcurl,
66 except that the CURLINFO_ prefix has been removed.
67 <em>Result</em> contains an integer, float or string, depending on
68 which option is given. The <code>getinfo</code> method should
69 not be called unless <code>perform</code> has been called and
70 finished.</p>
71
72 <p>Example usage:</p>
73
74 <pre>
75 import pycurl
76 c = pycurl.Curl()
77 c.setopt(pycurl.URL, "http://sf.net")
78 c.setopt(pycurl.FOLLOWLOCATION, 1)
79 c.perform()
80 print c.getinfo(pycurl.HTTP_CODE), c.getinfo(pycurl.EFFECTIVE_URL)
81 ...
82 --&gt; 200 "http://sourceforge.net/"
83 </pre>
84 </dd>
85
86 <dt><code>errstr()</code> -&gt; <em>String</em></dt>
87 <dd>
88 <p>Returns the internal libcurl error buffer of this handle as a string.</p>
89 </dd>
90 </dl>
91
92
93 <hr />
94 <p>
95   <a href="http://validator.w3.org/check/referer"><img align="right"
96      src="http://www.w3.org/Icons/valid-xhtml10"
97      alt="Valid XHTML 1.0!" height="31" width="88" border="0" /></a>
98   $Id: curlobject.html,v 1.14 2005/02/11 11:09:09 mfx Exp $
99 </p>
100
101 </body>
102 </html>