blob: dc69b47809dfe6aaf7a077f6de678cbfddd5b5a7 [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">
62 <td><nobr><b><tt id='l2h-11' xml:id='l2h-11' class="method">request</tt></b>(</nobr></td>
63 <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">
90 <td><nobr><b><tt id='l2h-12' xml:id='l2h-12' class="method">add_credentials</tt></b>(</nobr></td>
91 <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">
99 <td><nobr><b><tt id='l2h-13' xml:id='l2h-13' class="method">clear_credentials</tt></b>(</nobr></td>
100 <td><var></var>)</td></tr></table></dt>
101<dd>
102Remove all the names and passwords used for authentication.
103</dl>
104
105<P>
106<dl><dt><b><tt id='l2h-14' xml:id='l2h-14' class="member">follow_all_redirects</tt></b></dt>
107<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>
114<dl><dt><b><tt id='l2h-15' xml:id='l2h-15' class="member">ignore_etag</tt></b></dt>
115<dd>
116Defaults to <code>False</code>. If True, then any etags present in the cached response
117are ignored when processing the current request, i.e. httplib2 does *not* use
118'if-match' for PUT or 'if-none-match' when GET or HEAD requests are made. This
119is mainly to deal with broken servers which supply an etag, but change it capriciously.
jcgregorio26c0cd72006-07-03 17:36:17 +0000120</dl>
121
122<P>
123
124<DIV CLASS="navigation">
125<div class='online-navigation'>
126<p></p><hr />
127<table align="center" width="100%" cellpadding="0" cellspacing="2">
128<tr>
129<td class='online-navigation'><a rel="prev" title="1.1 httplib2 A comprehensive"
130 href="module-httplib2.html"><img src='previous.png'
131 border='0' height='32' alt='Previous Page' width='32' /></A></td>
132<td class='online-navigation'><a rel="parent" title="1.1 httplib2 A comprehensive"
133 href="module-httplib2.html"><img src='up.png'
134 border='0' height='32' alt='Up One Level' width='32' /></A></td>
135<td class='online-navigation'><a rel="next" title="1.1.2 Cache Objects"
136 href="cache-objects.html"><img src='next.png'
137 border='0' height='32' alt='Next Page' width='32' /></A></td>
138<td align="center" width="100%">The httplib2 Library</td>
139<td class='online-navigation'><a rel="contents" title="Table of Contents"
140 href="contents.html"><img src='contents.png'
141 border='0' height='32' alt='Contents' width='32' /></A></td>
142<td class='online-navigation'><img src='blank.png'
143 border='0' height='32' alt='' width='32' /></td>
144<td class='online-navigation'><img src='blank.png'
145 border='0' height='32' alt='' width='32' /></td>
146</tr></table>
147<div class='online-navigation'>
148<b class="navlabel">Previous:</b>
149<a class="sectref" rel="prev" href="module-httplib2.html">1.1 httplib2 A comprehensive</A>
150<b class="navlabel">Up:</b>
151<a class="sectref" rel="parent" href="module-httplib2.html">1.1 httplib2 A comprehensive</A>
152<b class="navlabel">Next:</b>
153<a class="sectref" rel="next" href="cache-objects.html">1.1.2 Cache Objects</A>
154</div>
155</div>
156<hr />
157<span class="release-info">Release 0.2, documentation updated on July 2, 2006.</span>
158</DIV>
159<!--End of Navigation Panel-->
160
161</BODY>
162</HTML>