blob: 259697493b0d28e579ade53fa05e962b9c60f17a [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>
jcgregorio26c0cd72006-07-03 17:36:17 +000091 <td><var>name, password</var>)</td></tr></table></dt>
92<dd>
93Adds a name and password that will be used when a request
94requires authentication.
95</dl>
96
97<P>
98<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
jcgregoriocde4f092007-03-08 21:59:04 +000099 <td><nobr><b><tt id='l2h-16' xml:id='l2h-16' class="method">clear_credentials</tt></b>(</nobr></td>
jcgregorio26c0cd72006-07-03 17:36:17 +0000100 <td><var></var>)</td></tr></table></dt>
101<dd>
102Remove all the names and passwords used for authentication.
103</dl>
104
105<P>
jcgregoriocde4f092007-03-08 21:59:04 +0000106<dl><dt><b><tt id='l2h-17' xml:id='l2h-17' class="member">follow_all_redirects</tt></b></dt>
jcgregorio26c0cd72006-07-03 17:36:17 +0000107<dd>
jcgregoriof76c9512006-11-07 18:01:50 +0000108If <code>False</code>, which is the default, only safe redirects are followed, where
jcgregorio26c0cd72006-07-03 17:36:17 +0000109safe means that the client is only doing a <code>GET</code> or <code>HEAD</code> on the
jcgregoriof76c9512006-11-07 18:01:50 +0000110URI to which it is being redirected. If <code>True</code> then all redirects are followed.
111</dl>
112
113<P>
jcgregoriocde4f092007-03-08 21:59:04 +0000114<dl><dt><b><tt id='l2h-18' xml:id='l2h-18' class="member">force_exception_to_status_code</tt></b></dt>
115<dd>
116If <code>True</code>, which is the default, then no <tt class="module">httplib2</tt> exceptions will be thrown. Instead,
117those error conditions will be turned into <tt class="class">Response</tt> objects
118that will be returned normally.
119
120<P>
121If <code>False</code>, then exceptions will be thrown.
122</dl>
123
124<P>
125<dl><dt><b><tt id='l2h-19' xml:id='l2h-19' class="member">ignore_etag</tt></b></dt>
jcgregoriof76c9512006-11-07 18:01:50 +0000126<dd>
127Defaults to <code>False</code>. If True, then any etags present in the cached response
128are ignored when processing the current request, i.e. httplib2 does *not* use
129'if-match' for PUT or 'if-none-match' when GET or HEAD requests are made. This
130is mainly to deal with broken servers which supply an etag, but change it capriciously.
jcgregorio26c0cd72006-07-03 17:36:17 +0000131</dl>
132
133<P>
134
135<DIV CLASS="navigation">
136<div class='online-navigation'>
137<p></p><hr />
138<table align="center" width="100%" cellpadding="0" cellspacing="2">
139<tr>
140<td class='online-navigation'><a rel="prev" title="1.1 httplib2 A comprehensive"
141 href="module-httplib2.html"><img src='previous.png'
142 border='0' height='32' alt='Previous Page' width='32' /></A></td>
143<td class='online-navigation'><a rel="parent" title="1.1 httplib2 A comprehensive"
144 href="module-httplib2.html"><img src='up.png'
145 border='0' height='32' alt='Up One Level' width='32' /></A></td>
146<td class='online-navigation'><a rel="next" title="1.1.2 Cache Objects"
147 href="cache-objects.html"><img src='next.png'
148 border='0' height='32' alt='Next Page' width='32' /></A></td>
149<td align="center" width="100%">The httplib2 Library</td>
150<td class='online-navigation'><a rel="contents" title="Table of Contents"
151 href="contents.html"><img src='contents.png'
152 border='0' height='32' alt='Contents' width='32' /></A></td>
153<td class='online-navigation'><img src='blank.png'
154 border='0' height='32' alt='' width='32' /></td>
155<td class='online-navigation'><img src='blank.png'
156 border='0' height='32' alt='' width='32' /></td>
157</tr></table>
158<div class='online-navigation'>
159<b class="navlabel">Previous:</b>
160<a class="sectref" rel="prev" href="module-httplib2.html">1.1 httplib2 A comprehensive</A>
161<b class="navlabel">Up:</b>
162<a class="sectref" rel="parent" href="module-httplib2.html">1.1 httplib2 A comprehensive</A>
163<b class="navlabel">Next:</b>
164<a class="sectref" rel="next" href="cache-objects.html">1.1.2 Cache Objects</A>
165</div>
166</div>
167<hr />
jcgregoriocde4f092007-03-08 21:59:04 +0000168<span class="release-info">Release 0.3, documentation updated on Mar 8, 2007.</span>
jcgregorio26c0cd72006-07-03 17:36:17 +0000169</DIV>
170<!--End of Navigation Panel-->
171
172</BODY>
173</HTML>