blob: 137482ccc138bcfc620e7c62fd0499208dfa325c [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>
jcgregoriocde4f092007-03-08 21:59:04 +0000112The <tt class="module">httplib2</tt> module may raise the following Exceptions. Note that
113there is an option that turns exceptions into
114normal responses with an HTTP status code indicating
115an error occured. See <tt class="member">Http.force_exception_to_status_code</tt>
jcgregorio26c0cd72006-07-03 17:36:17 +0000116
117<P>
118<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-3' xml:id='l2h-3' class="exception">HttpLib2Error</tt></b></dt>
119<dd>
120The Base Exception for all exceptions raised by httplib2.
121</dd></dl>
122
123<P>
124<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-4' xml:id='l2h-4' class="exception">RedirectMissingLocation</tt></b></dt>
125<dd>
126A 3xx redirect response code was provided but no Location: header
127was provided to point to the new location.
128</dd></dl>
129
130<P>
131<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-5' xml:id='l2h-5' class="exception">RedirectLimit</tt></b></dt>
132<dd>
133The maximum number of redirections was reached without coming to a final URI.
134</dd></dl>
135
136<P>
jcgregoriocde4f092007-03-08 21:59:04 +0000137<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-6' xml:id='l2h-6' class="exception">ServerNotFoundError</tt></b></dt>
138<dd>
139Unable to resolve the host name given.
140</dd></dl>
141
142<P>
143<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-7' xml:id='l2h-7' class="exception">RelativeURIError</tt></b></dt>
144<dd>
145A relative, as opposed to an absolute URI, was passed into request().
146</dd></dl>
147
148<P>
149<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-8' xml:id='l2h-8' class="exception">FailedToDecompressContent</tt></b></dt>
jcgregorio26c0cd72006-07-03 17:36:17 +0000150<dd>
151The headers claimed that the content of the response was compressed but the
152decompression algorithm applied to the content failed.
153</dd></dl>
154
155<P>
jcgregoriocde4f092007-03-08 21:59:04 +0000156<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-9' xml:id='l2h-9' class="exception">UnimplementedDigestAuthOptionError</tt></b></dt>
jcgregorio26c0cd72006-07-03 17:36:17 +0000157<dd>
158The server requested a type of Digest authentication that we
159are unfamiliar with.
160</dd></dl>
161
162<P>
jcgregoriocde4f092007-03-08 21:59:04 +0000163<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-10' xml:id='l2h-10' class="exception">UnimplementedHmacDigestAuthOptionError</tt></b></dt>
jcgregorio26c0cd72006-07-03 17:36:17 +0000164<dd>
165The server requested a type of HMACDigest authentication that we
166are unfamiliar with.
167</dd></dl>
168
169<P>
170<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
jcgregoriocde4f092007-03-08 21:59:04 +0000171 <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-11' xml:id='l2h-11' class="class">Http</tt></b>(</nobr></td>
jcgregorio26c0cd72006-07-03 17:36:17 +0000172 <td><var></var><big>[</big><var>cache=None</var><big>]</big><var></var>)</td></tr></table></dt>
173<dd>
174The class that represents a client HTTP interface.
175The <var>cache</var> parameter is either the name of a directory
176to be used as a flat file cache, or it must an object that
177implements the required caching interface.
178</dl>
179
180<P>
181<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
jcgregoriocde4f092007-03-08 21:59:04 +0000182 <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-12' xml:id='l2h-12' class="class">Response</tt></b>(</nobr></td>
jcgregorio26c0cd72006-07-03 17:36:17 +0000183 <td><var>info</var>)</td></tr></table></dt>
184<dd>
185Response is a subclass of <tt class="class">dict</tt> and instances of this
186class are returned from calls
187to Http.request. The <var>info</var> parameter is either
188an <tt class="class">rfc822.Message</tt> or an <tt class="class">httplib.HTTPResponse</tt> object.
189</dl>
190
191<P>
jcgregorioee542cc2006-11-16 04:43:19 +0000192<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
jcgregoriocde4f092007-03-08 21:59:04 +0000193 <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-13' xml:id='l2h-13' class="class">FileCache</tt></b>(</nobr></td>
jcgregorioee542cc2006-11-16 04:43:19 +0000194 <td><var>dir_name, </var><big>[</big><var>safe=safename</var><big>]</big><var></var>)</td></tr></table></dt>
195<dd>
196FileCache implements a Cache as a directory of files.
197The <var>dir_name</var> parameter is
198the name of the directory to use. If the directory does
199not exist then FileCache attempts to create the directory.
200The optional <var>safe</var> parameter is a funtion which generates
201the cache filename for each URI. A FileCache object is
202constructed and used for caching when you pass a directory name
203into the constructor of <tt class="class">Http</tt>.
204</dl>
205
206<P>
jcgregorio26c0cd72006-07-03 17:36:17 +0000207
208<p><br /></p><hr class='online-navigation' />
209<div class='online-navigation'>
210<!--Table of Child-Links-->
211<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>
212
213<UL CLASS="ChildLinks">
214<LI><A href="http-objects.html">1.1.1 Http Objects</a>
215<LI><A href="cache-objects.html">1.1.2 Cache Objects</a>
216<LI><A href="response-objects.html">1.1.3 Response Objects</a>
217<LI><A href="httplib2-example.html">1.1.4 Examples</a>
218</ul>
219<!--End of Table of Child-Links-->
220</div>
221
222<DIV CLASS="navigation">
223<div class='online-navigation'>
224<p></p><hr />
225<table align="center" width="100%" cellpadding="0" cellspacing="2">
226<tr>
227<td class='online-navigation'><a rel="prev" title="1. Reference"
228 href="node2.html"><img src='previous.png'
229 border='0' height='32' alt='Previous Page' width='32' /></A></td>
230<td class='online-navigation'><a rel="parent" title="1. Reference"
231 href="node2.html"><img src='up.png'
232 border='0' height='32' alt='Up One Level' width='32' /></A></td>
233<td class='online-navigation'><a rel="next" title="1.1.1 Http Objects"
234 href="http-objects.html"><img src='next.png'
235 border='0' height='32' alt='Next Page' width='32' /></A></td>
236<td align="center" width="100%">The httplib2 Library</td>
237<td class='online-navigation'><a rel="contents" title="Table of Contents"
238 href="contents.html"><img src='contents.png'
239 border='0' height='32' alt='Contents' width='32' /></A></td>
240<td class='online-navigation'><img src='blank.png'
241 border='0' height='32' alt='' width='32' /></td>
242<td class='online-navigation'><img src='blank.png'
243 border='0' height='32' alt='' width='32' /></td>
244</tr></table>
245<div class='online-navigation'>
246<b class="navlabel">Previous:</b>
247<a class="sectref" rel="prev" href="node2.html">1. Reference</A>
248<b class="navlabel">Up:</b>
249<a class="sectref" rel="parent" href="node2.html">1. Reference</A>
250<b class="navlabel">Next:</b>
251<a class="sectref" rel="next" href="http-objects.html">1.1.1 Http Objects</A>
252</div>
253</div>
254<hr />
jcgregoriocde4f092007-03-08 21:59:04 +0000255<span class="release-info">Release 0.3, documentation updated on Mar 8, 2007.</span>
jcgregorio26c0cd72006-07-03 17:36:17 +0000256</DIV>
257<!--End of Navigation Panel-->
258
259</BODY>
260</HTML>