blob: 5ead329c2b5eafda823d5b6d9f0c319c955fe127 [file] [log] [blame]
jcgregorio26c0cd72006-07-03 17:36:17 +00001<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="ref.css" type='text/css' />
5<link rel="first" href="ref.html" title='The httplib2 Library' />
6<link rel='contents' href='contents.html' title="Contents" />
7<link rel='last' href='about.html' title='About this document...' />
8<link rel='help' href='about.html' title='About this document...' />
9<link rel="prev" href="node2.html" />
10<link rel="parent" href="node2.html" />
11<link rel="next" href="http-objects.html" />
12<meta name='aesop' content='information' />
13<title>1.1 httplib2 A comprehensive HTTP client library. </title>
14</head>
15<body>
16<DIV CLASS="navigation">
17<div id='top-navigation-panel' xml:id='top-navigation-panel'>
18<table align="center" width="100%" cellpadding="0" cellspacing="2">
19<tr>
20<td class='online-navigation'><a rel="prev" title="1. Reference"
21 href="node2.html"><img src='previous.png'
22 border='0' height='32' alt='Previous Page' width='32' /></A></td>
23<td class='online-navigation'><a rel="parent" title="1. Reference"
24 href="node2.html"><img src='up.png'
25 border='0' height='32' alt='Up One Level' width='32' /></A></td>
26<td class='online-navigation'><a rel="next" title="1.1.1 Http Objects"
27 href="http-objects.html"><img src='next.png'
28 border='0' height='32' alt='Next Page' width='32' /></A></td>
29<td align="center" width="100%">The httplib2 Library</td>
30<td class='online-navigation'><a rel="contents" title="Table of Contents"
31 href="contents.html"><img src='contents.png'
32 border='0' height='32' alt='Contents' width='32' /></A></td>
33<td class='online-navigation'><img src='blank.png'
34 border='0' height='32' alt='' width='32' /></td>
35<td class='online-navigation'><img src='blank.png'
36 border='0' height='32' alt='' width='32' /></td>
37</tr></table>
38<div class='online-navigation'>
39<b class="navlabel">Previous:</b>
40<a class="sectref" rel="prev" href="node2.html">1. Reference</A>
41<b class="navlabel">Up:</b>
42<a class="sectref" rel="parent" href="node2.html">1. Reference</A>
43<b class="navlabel">Next:</b>
44<a class="sectref" rel="next" href="http-objects.html">1.1.1 Http Objects</A>
45</div>
46<hr /></div>
47</DIV>
48<!--End of Navigation Panel-->
49
50<H1><A NAME="SECTION002100000000000000000">
511.1 <tt class="module">httplib2</tt>
52 A comprehensive HTTP client library. </A>
53</H1>
54
55<P>
56<A NAME="module-httplib2"></A>
57<P>
58
59<P>
60
61<P>
62The <tt class="module">httplib2</tt> module is a comprehensive HTTP client library with the following features:
63
64<P>
65<DL>
66<DT><STRONG>HTTP and HTTPS</STRONG></DT>
67<DD>HTTPS support is only available if the socket module was compiled with SSL support.
68</DD>
69<DT><STRONG>Keep-Alive</STRONG></DT>
70<DD>Supports HTTP 1.1 Keep-Alive, keeping the socket open and performing multiple requests over the same connection if possible.
71</DD>
72<DT><STRONG>Authentication</STRONG></DT>
73<DD>The following three types of HTTP Authentication are supported. These can be used over both HTTP and HTTPS.
74
75<UL>
76<LI>Digest
77</LI>
78<LI>Basic
79</LI>
80<LI>WSSE
81
82</LI>
83</UL>
84</DD>
85<DT><STRONG>Caching</STRONG></DT>
86<DD>The module can optionally operate with a private cache that understands the Cache-Control: header and uses both the ETag and Last-Modified cache validators.
87</DD>
88<DT><STRONG>All Methods</STRONG></DT>
89<DD>The module can handle any HTTP request method, not just GET and POST.
90</DD>
91<DT><STRONG>Redirects</STRONG></DT>
92<DD>Automatically follows 3XX redirects on GETs.
93</DD>
94<DT><STRONG>Compression</STRONG></DT>
95<DD>Handles both 'deflate' and 'gzip' types of compression.
96</DD>
97<DT><STRONG>Lost update support</STRONG></DT>
98<DD>Automatically adds back ETags into PUT requests to resources we have already cached. This implements Section 3.2 of Detecting the Lost Update Problem Using Unreserved Checkout
99</DD>
100</DL>
101
102<P>
103The <tt class="module">httplib2</tt> module defines the following variables:
104
105<P>
106<dl><dt><b><tt id='l2h-2' xml:id='l2h-2'>debuglevel</tt></b></dt>
107<dd>
108The amount of debugging information to print. The default is 0.
109</dd></dl>
110
111<P>
112The <tt class="module">httplib2</tt> module may raise the following Exceptions:
113
114<P>
115<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-3' xml:id='l2h-3' class="exception">HttpLib2Error</tt></b></dt>
116<dd>
117The Base Exception for all exceptions raised by httplib2.
118</dd></dl>
119
120<P>
121<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-4' xml:id='l2h-4' class="exception">RedirectMissingLocation</tt></b></dt>
122<dd>
123A 3xx redirect response code was provided but no Location: header
124was provided to point to the new location.
125</dd></dl>
126
127<P>
128<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-5' xml:id='l2h-5' class="exception">RedirectLimit</tt></b></dt>
129<dd>
130The maximum number of redirections was reached without coming to a final URI.
131</dd></dl>
132
133<P>
134<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-6' xml:id='l2h-6' class="exception">FailedToDecompressContent</tt></b></dt>
135<dd>
136The headers claimed that the content of the response was compressed but the
137decompression algorithm applied to the content failed.
138</dd></dl>
139
140<P>
141<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-7' xml:id='l2h-7' class="exception">UnimplementedDigestAuthOptionError</tt></b></dt>
142<dd>
143The server requested a type of Digest authentication that we
144are unfamiliar with.
145</dd></dl>
146
147<P>
148<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-8' xml:id='l2h-8' class="exception">UnimplementedHmacDigestAuthOptionError</tt></b></dt>
149<dd>
150The server requested a type of HMACDigest authentication that we
151are unfamiliar with.
152</dd></dl>
153
154<P>
155<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
156 <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-9' xml:id='l2h-9' class="class">Http</tt></b>(</nobr></td>
157 <td><var></var><big>[</big><var>cache=None</var><big>]</big><var></var>)</td></tr></table></dt>
158<dd>
159The class that represents a client HTTP interface.
160The <var>cache</var> parameter is either the name of a directory
161to be used as a flat file cache, or it must an object that
162implements the required caching interface.
163</dl>
164
165<P>
166<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
167 <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-10' xml:id='l2h-10' class="class">Response</tt></b>(</nobr></td>
168 <td><var>info</var>)</td></tr></table></dt>
169<dd>
170Response is a subclass of <tt class="class">dict</tt> and instances of this
171class are returned from calls
172to Http.request. The <var>info</var> parameter is either
173an <tt class="class">rfc822.Message</tt> or an <tt class="class">httplib.HTTPResponse</tt> object.
174</dl>
175
176<P>
jcgregorioee542cc2006-11-16 04:43:19 +0000177<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
178 <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-11' xml:id='l2h-11' class="class">FileCache</tt></b>(</nobr></td>
179 <td><var>dir_name, </var><big>[</big><var>safe=safename</var><big>]</big><var></var>)</td></tr></table></dt>
180<dd>
181FileCache implements a Cache as a directory of files.
182The <var>dir_name</var> parameter is
183the name of the directory to use. If the directory does
184not exist then FileCache attempts to create the directory.
185The optional <var>safe</var> parameter is a funtion which generates
186the cache filename for each URI. A FileCache object is
187constructed and used for caching when you pass a directory name
188into the constructor of <tt class="class">Http</tt>.
189</dl>
190
191<P>
jcgregorio26c0cd72006-07-03 17:36:17 +0000192
193<p><br /></p><hr class='online-navigation' />
194<div class='online-navigation'>
195<!--Table of Child-Links-->
196<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>
197
198<UL CLASS="ChildLinks">
199<LI><A href="http-objects.html">1.1.1 Http Objects</a>
200<LI><A href="cache-objects.html">1.1.2 Cache Objects</a>
201<LI><A href="response-objects.html">1.1.3 Response Objects</a>
202<LI><A href="httplib2-example.html">1.1.4 Examples</a>
203</ul>
204<!--End of Table of Child-Links-->
205</div>
206
207<DIV CLASS="navigation">
208<div class='online-navigation'>
209<p></p><hr />
210<table align="center" width="100%" cellpadding="0" cellspacing="2">
211<tr>
212<td class='online-navigation'><a rel="prev" title="1. Reference"
213 href="node2.html"><img src='previous.png'
214 border='0' height='32' alt='Previous Page' width='32' /></A></td>
215<td class='online-navigation'><a rel="parent" title="1. Reference"
216 href="node2.html"><img src='up.png'
217 border='0' height='32' alt='Up One Level' width='32' /></A></td>
218<td class='online-navigation'><a rel="next" title="1.1.1 Http Objects"
219 href="http-objects.html"><img src='next.png'
220 border='0' height='32' alt='Next Page' width='32' /></A></td>
221<td align="center" width="100%">The httplib2 Library</td>
222<td class='online-navigation'><a rel="contents" title="Table of Contents"
223 href="contents.html"><img src='contents.png'
224 border='0' height='32' alt='Contents' width='32' /></A></td>
225<td class='online-navigation'><img src='blank.png'
226 border='0' height='32' alt='' width='32' /></td>
227<td class='online-navigation'><img src='blank.png'
228 border='0' height='32' alt='' width='32' /></td>
229</tr></table>
230<div class='online-navigation'>
231<b class="navlabel">Previous:</b>
232<a class="sectref" rel="prev" href="node2.html">1. Reference</A>
233<b class="navlabel">Up:</b>
234<a class="sectref" rel="parent" href="node2.html">1. Reference</A>
235<b class="navlabel">Next:</b>
236<a class="sectref" rel="next" href="http-objects.html">1.1.1 Http Objects</A>
237</div>
238</div>
239<hr />
240<span class="release-info">Release 0.2, documentation updated on July 2, 2006.</span>
241</DIV>
242<!--End of Navigation Panel-->
243
244</BODY>
245</HTML>