1<!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 http-equiv="Content-Type" content="text/html; charset=utf-8" /> 14<meta name='aesop' content='information' /> 15<title>1.1.1 Http Objects</title> 16</head> 17<body> 18<div class="navigation"> 19<div id='top-navigation-panel' xml:id='top-navigation-panel'> 20<table align="center" width="100%" cellpadding="0" cellspacing="2"> 21<tr> 22<td class='online-navigation'><a rel="prev" title="1.1 httplib2 A comprehensive" 23 href="module-httplib2.html"><img src='previous.png' 24 border='0' height='32' alt='Previous Page' width='32' /></a></td> 25<td class='online-navigation'><a rel="parent" title="1.1 httplib2 A comprehensive" 26 href="module-httplib2.html"><img src='up.png' 27 border='0' height='32' alt='Up one Level' width='32' /></a></td> 28<td class='online-navigation'><a rel="next" title="1.1.2 cache Objects" 29 href="cache-objects.html"><img src='next.png' 30 border='0' height='32' alt='Next Page' width='32' /></a></td> 31<td align="center" width="100%">The httplib2 Library</td> 32<td class='online-navigation'><a rel="contents" title="Table of Contents" 33 href="contents.html"><img src='contents.png' 34 border='0' height='32' alt='Contents' width='32' /></a></td> 35<td class='online-navigation'><img src='blank.png' 36 border='0' height='32' alt='' width='32' /></td> 37<td class='online-navigation'><img src='blank.png' 38 border='0' height='32' alt='' width='32' /></td> 39</tr></table> 40<div class='online-navigation'> 41<b class="navlabel">Previous:</b> 42<a class="sectref" rel="prev" href="module-httplib2.html">1.1 httplib2 A comprehensive</a> 43<b class="navlabel">Up:</b> 44<a class="sectref" rel="parent" href="module-httplib2.html">1.1 httplib2 A comprehensive</a> 45<b class="navlabel">Next:</b> 46<a class="sectref" rel="next" href="cache-objects.html">1.1.2 Cache Objects</a> 47</div> 48<hr /></div> 49</div> 50<!--End of Navigation Panel--> 51 52<h2><a name="SECTION002110000000000000000"></a> 53<a name="http-objects"></a> 54<br> 551.1.1 Http Objects 56</h2> 57 58<p> 59Http objects have the following methods: 60 61<p> 62<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> 63 <td><nobr><b><tt id='l2h-15' xml:id='l2h-15' class="method">request</tt></b>(</nobr></td> 64 <td><var>uri, </var><big>[</big><var>method="GET", body=None, headers=None, redirections=DEFAULT_MAX_REDIRECTS, connection_type=None</var><big>]</big><var></var>)</td></tr></table></dt> 65<dd> 66Performs a single HTTP request. 67The <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. 68 69<p> 70The <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 71on the methods allowed. 72 73<p> 74The <var>body</var> is the entity body to be sent with the request. It is a string 75object. 76 77<p> 78Any extra headers that are to be sent with the request should be provided in the 79<var>headers</var> dictionary. 80 81<p> 82The maximum number of redirect to follow before raising an exception is <var>redirections</var>. The default is 5. 83 84<p> 85The <var>connection_type</var> is the type of connection object to use. The supplied class 86should implement the interface of httplib.HTTPConnection. 87 88<p> 89The return value is a tuple of (response, content), the first being and instance of the 90<tt class="class">Response</tt> class, the second being a string that contains the response entity body. 91</dl> 92 93<p> 94<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> 95 <td><nobr><b><tt id='l2h-16' xml:id='l2h-16' class="method">add_credentials</tt></b>(</nobr></td> 96 <td><var>name, password, </var><big>[</big><var>domain=None</var><big>]</big><var></var>)</td></tr></table></dt> 97<dd> 98Adds a name and password that will be used when a request 99requires authentication. Supplying the optional <var>domain</var> name will 100restrict these credentials to only be sent to the specified 101domain. If <var>domain</var> is not specified then the given credentials will 102be used to try to satisfy every HTTP 401 challenge. 103</dl> 104 105<p> 106<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> 107 <td><nobr><b><tt id='l2h-17' xml:id='l2h-17' class="method">add_certificate</tt></b>(</nobr></td> 108 <td><var>key, cert, domain</var>)</td></tr></table></dt> 109<dd> 110Add a <var>key</var> and <var>cert</var> that will be used for an SSL connection 111to the specified domain. <var>keyfile</var> is the name of a PEM formatted 112file that contains your private key. <var>certfile</var> is a PEM formatted certificate chain file. 113</dl> 114 115<p> 116<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> 117 <td><nobr><b><tt id='l2h-18' xml:id='l2h-18' class="method">clear_credentials</tt></b>(</nobr></td> 118 <td><var></var>)</td></tr></table></dt> 119<dd> 120Remove all the names and passwords used for authentication. 121</dl> 122 123<p> 124<dl><dt><b><tt id='l2h-19' xml:id='l2h-19' class="member">follow_redirects</tt></b></dt> 125<dd> 126If <code>True</code>, which is the default, safe redirects are followed, where 127safe means that the client is only doing a <code>GET</code> or <code>HEAD</code> on the 128URI to which it is being redirected. If <code>False</code> then no redirects are followed. 129Note that a False 'follow_redirects' takes precedence over a True 'follow_all_redirects'. 130Another way of saying that is for 'follow_all_redirects' to have any affect, 'follow_redirects' 131must be True. 132</dl> 133 134<p> 135<dl><dt><b><tt id='l2h-20' xml:id='l2h-20' class="member">follow_all_redirects</tt></b></dt> 136<dd> 137If <code>False</code>, which is the default, only safe redirects are followed, where 138safe means that the client is only doing a <code>GET</code> or <code>HEAD</code> on the 139URI to which it is being redirected. If <code>True</code> then all redirects are followed. 140Note that a False 'follow_redirects' takes precedence over a True 'follow_all_redirects'. 141Another way of saying that is for 'follow_all_redirects' to have any affect, 'follow_redirects' 142must be True. 143</dl> 144 145<p> 146<dl><dt><b><tt id='l2h-21' xml:id='l2h-21' class="member">force_exception_to_status_code</tt></b></dt> 147<dd> 148If <code>True</code>, which is the default, then no <tt class="module">httplib2</tt> exceptions will be thrown. Instead, 149those error conditions will be turned into <tt class="class">Response</tt> objects 150that will be returned normally. 151 152<p> 153If <code>False</code>, then exceptions will be thrown. 154</dl> 155 156<p> 157<dl><dt><b><tt id='l2h-22' xml:id='l2h-22' class="member">ignore_etag</tt></b></dt> 158<dd> 159Defaults to <code>False</code>. If <code>True</code>, then any etags present in the cached response 160are ignored when processing the current request, i.e. httplib2 does <strong>not</strong> use 161'if-match' for PUT or 'if-none-match' when GET or HEAD requests are made. This 162is mainly to deal with broken servers which supply an etag, but change it capriciously. 163</dl> 164 165<p> 166 167<div class="navigation"> 168<div class='online-navigation'> 169<p></p><hr /> 170<table align="center" width="100%" cellpadding="0" cellspacing="2"> 171<tr> 172<td class='online-navigation'><a rel="prev" title="1.1 httplib2 A comprehensive" 173 href="module-httplib2.html"><img src='previous.png' 174 border='0' height='32' alt='Previous Page' width='32' /></a></td> 175<td class='online-navigation'><a rel="parent" title="1.1 httplib2 A comprehensive" 176 href="module-httplib2.html"><img src='up.png' 177 border='0' height='32' alt='Up one Level' width='32' /></a></td> 178<td class='online-navigation'><a rel="next" title="1.1.2 cache Objects" 179 href="cache-objects.html"><img src='next.png' 180 border='0' height='32' alt='Next Page' width='32' /></a></td> 181<td align="center" width="100%">The httplib2 Library</td> 182<td class='online-navigation'><a rel="contents" title="Table of Contents" 183 href="contents.html"><img src='contents.png' 184 border='0' height='32' alt='Contents' width='32' /></a></td> 185<td class='online-navigation'><img src='blank.png' 186 border='0' height='32' alt='' width='32' /></td> 187<td class='online-navigation'><img src='blank.png' 188 border='0' height='32' alt='' width='32' /></td> 189</tr></table> 190<div class='online-navigation'> 191<b class="navlabel">Previous:</b> 192<a class="sectref" rel="prev" href="module-httplib2.html">1.1 httplib2 A comprehensive</a> 193<b class="navlabel">Up:</b> 194<a class="sectref" rel="parent" href="module-httplib2.html">1.1 httplib2 A comprehensive</a> 195<b class="navlabel">Next:</b> 196<a class="sectref" rel="next" href="cache-objects.html">1.1.2 Cache Objects</a> 197</div> 198</div> 199<hr /> 200<span class="release-info">Release 0.3, documentation updated on Mar 8, 2007.</span> 201</div> 202<!--End of Navigation Panel--> 203 204</body> 205</html> 206