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