blob: 0bcce378502edb8a5a9cebd1b75900a01713ab6a [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="next" href="cache-objects.html" />
10<link rel="prev" href="module-httplib2.html" />
11<link rel="parent" href="module-httplib2.html" />
12<link rel="next" href="cache-objects.html" />
13<meta name='aesop' content='information' />
14<title>1.1.1 Http Objects</title>
15</head>
16<body>
17<DIV CLASS="navigation">
18<div id='top-navigation-panel' xml:id='top-navigation-panel'>
19<table align="center" width="100%" cellpadding="0" cellspacing="2">
20<tr>
21<td class='online-navigation'><a rel="prev" title="1.1 httplib2 A comprehensive"
22 href="module-httplib2.html"><img src='previous.png'
23 border='0' height='32' alt='Previous Page' width='32' /></A></td>
24<td class='online-navigation'><a rel="parent" title="1.1 httplib2 A comprehensive"
25 href="module-httplib2.html"><img src='up.png'
26 border='0' height='32' alt='Up One Level' width='32' /></A></td>
27<td class='online-navigation'><a rel="next" title="1.1.2 Cache Objects"
28 href="cache-objects.html"><img src='next.png'
29 border='0' height='32' alt='Next Page' width='32' /></A></td>
30<td align="center" width="100%">The httplib2 Library</td>
31<td class='online-navigation'><a rel="contents" title="Table of Contents"
32 href="contents.html"><img src='contents.png'
33 border='0' height='32' alt='Contents' width='32' /></A></td>
34<td class='online-navigation'><img src='blank.png'
35 border='0' height='32' alt='' width='32' /></td>
36<td class='online-navigation'><img src='blank.png'
37 border='0' height='32' alt='' width='32' /></td>
38</tr></table>
39<div class='online-navigation'>
40<b class="navlabel">Previous:</b>
41<a class="sectref" rel="prev" href="module-httplib2.html">1.1 httplib2 A comprehensive</A>
42<b class="navlabel">Up:</b>
43<a class="sectref" rel="parent" href="module-httplib2.html">1.1 httplib2 A comprehensive</A>
44<b class="navlabel">Next:</b>
45<a class="sectref" rel="next" href="cache-objects.html">1.1.2 Cache Objects</A>
46</div>
47<hr /></div>
48</DIV>
49<!--End of Navigation Panel-->
50
51<H2><A NAME="SECTION002110000000000000000"></A>
52<A NAME="http-objects"></A>
53<BR>
541.1.1 Http Objects
55</H2>
56
57<P>
58Http objects have the following methods:
59
60<P>
61<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
jcgregoriocde4f092007-03-08 21:59:04 +000062 <td><nobr><b><tt id='l2h-14' xml:id='l2h-14' class="method">request</tt></b>(</nobr></td>
jcgregorio26c0cd72006-07-03 17:36:17 +000063 <td><var>uri, </var><big>[</big><var>method="GET", body=None, headers=None, redirections=DEFAULT_MAX_REDIRECTS</var><big>]</big><var></var>)</td></tr></table></dt>
64<dd>
65Performs a single HTTP request.
66The <var>uri</var> is the URI of the HTTP resource and can begin with either <code>http</code> or <code>https</code>. The value of <var>uri</var> must be an absolute URI.
67
68<P>
69The <var>method</var> is the HTTP method to perform, such as <code>GET</code>, <code>POST</code>, <code>DELETE</code>, etc. There is no restriction
70on the methods allowed.
71
72<P>
73The <var>body</var> is the entity body to be sent with the request. It is a string
74object.
75
76<P>
77Any extra headers that are to be sent with the request should be provided in the
78<var>headers</var> dictionary.
79
80<P>
81The maximum number of redirect to follow before raising an exception is <var>redirections</var>. The default is 5.
82
83<P>
84The return value is a tuple of (response, content), the first being and instance of the
85<tt class="class">Response</tt> class, the second being a string that contains the response entity body.
86</dl>
87
88<P>
89<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
jcgregoriocde4f092007-03-08 21:59:04 +000090 <td><nobr><b><tt id='l2h-15' xml:id='l2h-15' class="method">add_credentials</tt></b>(</nobr></td>
jcgregorio87eee732007-03-09 03:23:11 +000091 <td><var>name, password, </var><big>[</big><var>domain=None</var><big>]</big><var></var>)</td></tr></table></dt>
jcgregorio26c0cd72006-07-03 17:36:17 +000092<dd>
93Adds a name and password that will be used when a request
jcgregorio87eee732007-03-09 03:23:11 +000094requires authentication. Supplying the optional <var>domain</var> name will
95restrict these credentials to only be sent to the specified
96domain. If <var>domain</var> is not specified then the given credentials will
97be used to try to satisfy every HTTP 401 challenge.
jcgregorio26c0cd72006-07-03 17:36:17 +000098</dl>
99
100<P>
101<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
jcgregorio87eee732007-03-09 03:23:11 +0000102 <td><nobr><b><tt id='l2h-16' xml:id='l2h-16' class="method">add_certificate</tt></b>(</nobr></td>
103 <td><var>key, cert, domain</var>)</td></tr></table></dt>
104<dd>
105Add a <var>key</var> and <var>cert</var> that will be used for an SSL connection
106to the specified domain. <var>keyfile</var> is the name of a PEM formatted
107file that contains your private key. <var>certfile</var> is a PEM formatted certificate chain file.
108</dl>
109
110<P>
111<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
112 <td><nobr><b><tt id='l2h-17' xml:id='l2h-17' class="method">clear_credentials</tt></b>(</nobr></td>
jcgregorio26c0cd72006-07-03 17:36:17 +0000113 <td><var></var>)</td></tr></table></dt>
114<dd>
115Remove all the names and passwords used for authentication.
116</dl>
117
118<P>
jcgregorio87eee732007-03-09 03:23:11 +0000119<dl><dt><b><tt id='l2h-18' xml:id='l2h-18' class="member">follow_all_redirects</tt></b></dt>
jcgregorio26c0cd72006-07-03 17:36:17 +0000120<dd>
jcgregoriof76c9512006-11-07 18:01:50 +0000121If <code>False</code>, which is the default, only safe redirects are followed, where
jcgregorio26c0cd72006-07-03 17:36:17 +0000122safe means that the client is only doing a <code>GET</code> or <code>HEAD</code> on the
jcgregoriof76c9512006-11-07 18:01:50 +0000123URI to which it is being redirected. If <code>True</code> then all redirects are followed.
124</dl>
125
126<P>
jcgregorio87eee732007-03-09 03:23:11 +0000127<dl><dt><b><tt id='l2h-19' xml:id='l2h-19' class="member">force_exception_to_status_code</tt></b></dt>
jcgregoriocde4f092007-03-08 21:59:04 +0000128<dd>
129If <code>True</code>, which is the default, then no <tt class="module">httplib2</tt> exceptions will be thrown. Instead,
130those error conditions will be turned into <tt class="class">Response</tt> objects
131that will be returned normally.
132
133<P>
134If <code>False</code>, then exceptions will be thrown.
135</dl>
136
137<P>
jcgregorio87eee732007-03-09 03:23:11 +0000138<dl><dt><b><tt id='l2h-20' xml:id='l2h-20' class="member">ignore_etag</tt></b></dt>
jcgregoriof76c9512006-11-07 18:01:50 +0000139<dd>
jcgregorio87eee732007-03-09 03:23:11 +0000140Defaults to <code>False</code>. If <code>True</code>, then any etags present in the cached response
141are ignored when processing the current request, i.e. httplib2 does <strong>not</strong> use
jcgregoriof76c9512006-11-07 18:01:50 +0000142'if-match' for PUT or 'if-none-match' when GET or HEAD requests are made. This
143is mainly to deal with broken servers which supply an etag, but change it capriciously.
jcgregorio26c0cd72006-07-03 17:36:17 +0000144</dl>
145
146<P>
147
148<DIV CLASS="navigation">
149<div class='online-navigation'>
150<p></p><hr />
151<table align="center" width="100%" cellpadding="0" cellspacing="2">
152<tr>
153<td class='online-navigation'><a rel="prev" title="1.1 httplib2 A comprehensive"
154 href="module-httplib2.html"><img src='previous.png'
155 border='0' height='32' alt='Previous Page' width='32' /></A></td>
156<td class='online-navigation'><a rel="parent" title="1.1 httplib2 A comprehensive"
157 href="module-httplib2.html"><img src='up.png'
158 border='0' height='32' alt='Up One Level' width='32' /></A></td>
159<td class='online-navigation'><a rel="next" title="1.1.2 Cache Objects"
160 href="cache-objects.html"><img src='next.png'
161 border='0' height='32' alt='Next Page' width='32' /></A></td>
162<td align="center" width="100%">The httplib2 Library</td>
163<td class='online-navigation'><a rel="contents" title="Table of Contents"
164 href="contents.html"><img src='contents.png'
165 border='0' height='32' alt='Contents' width='32' /></A></td>
166<td class='online-navigation'><img src='blank.png'
167 border='0' height='32' alt='' width='32' /></td>
168<td class='online-navigation'><img src='blank.png'
169 border='0' height='32' alt='' width='32' /></td>
170</tr></table>
171<div class='online-navigation'>
172<b class="navlabel">Previous:</b>
173<a class="sectref" rel="prev" href="module-httplib2.html">1.1 httplib2 A comprehensive</A>
174<b class="navlabel">Up:</b>
175<a class="sectref" rel="parent" href="module-httplib2.html">1.1 httplib2 A comprehensive</A>
176<b class="navlabel">Next:</b>
177<a class="sectref" rel="next" href="cache-objects.html">1.1.2 Cache Objects</A>
178</div>
179</div>
180<hr />
jcgregoriocde4f092007-03-08 21:59:04 +0000181<span class="release-info">Release 0.3, documentation updated on Mar 8, 2007.</span>
jcgregorio26c0cd72006-07-03 17:36:17 +0000182</DIV>
183<!--End of Navigation Panel-->
184
185</BODY>
186</HTML>