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" /> |
| 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> |
| 54 | 1.1.1 Http Objects |
| 55 | </H2> |
| 56 | |
| 57 | <P> |
| 58 | Http objects have the following methods: |
| 59 | |
| 60 | <P> |
| 61 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
jcgregorio | cde4f09 | 2007-03-08 21:59:04 +0000 | [diff] [blame] | 62 | <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] | 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> |
| 65 | Performs a single HTTP request. |
| 66 | 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. |
| 67 | |
| 68 | <P> |
| 69 | 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 |
| 70 | on the methods allowed. |
| 71 | |
| 72 | <P> |
| 73 | The <var>body</var> is the entity body to be sent with the request. It is a string |
| 74 | object. |
| 75 | |
| 76 | <P> |
| 77 | Any extra headers that are to be sent with the request should be provided in the |
| 78 | <var>headers</var> dictionary. |
| 79 | |
| 80 | <P> |
| 81 | The maximum number of redirect to follow before raising an exception is <var>redirections</var>. The default is 5. |
| 82 | |
| 83 | <P> |
| 84 | The 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"> |
jcgregorio | cde4f09 | 2007-03-08 21:59:04 +0000 | [diff] [blame] | 90 | <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^] | 91 | <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] | 92 | <dd> |
| 93 | Adds a name and password that will be used when a request |
jcgregorio | 87eee73 | 2007-03-09 03:23:11 +0000 | [diff] [blame^] | 94 | requires authentication. Supplying the optional <var>domain</var> name will |
| 95 | restrict these credentials to only be sent to the specified |
| 96 | domain. If <var>domain</var> is not specified then the given credentials will |
| 97 | be used to try to satisfy every HTTP 401 challenge. |
jcgregorio | 26c0cd7 | 2006-07-03 17:36:17 +0000 | [diff] [blame] | 98 | </dl> |
| 99 | |
| 100 | <P> |
| 101 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
jcgregorio | 87eee73 | 2007-03-09 03:23:11 +0000 | [diff] [blame^] | 102 | <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> |
| 105 | Add a <var>key</var> and <var>cert</var> that will be used for an SSL connection |
| 106 | to the specified domain. <var>keyfile</var> is the name of a PEM formatted |
| 107 | file 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> |
jcgregorio | 26c0cd7 | 2006-07-03 17:36:17 +0000 | [diff] [blame] | 113 | <td><var></var>)</td></tr></table></dt> |
| 114 | <dd> |
| 115 | Remove all the names and passwords used for authentication. |
| 116 | </dl> |
| 117 | |
| 118 | <P> |
jcgregorio | 87eee73 | 2007-03-09 03:23:11 +0000 | [diff] [blame^] | 119 | <dl><dt><b><tt id='l2h-18' xml:id='l2h-18' class="member">follow_all_redirects</tt></b></dt> |
jcgregorio | 26c0cd7 | 2006-07-03 17:36:17 +0000 | [diff] [blame] | 120 | <dd> |
jcgregorio | f76c951 | 2006-11-07 18:01:50 +0000 | [diff] [blame] | 121 | 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] | 122 | 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] | 123 | URI to which it is being redirected. If <code>True</code> then all redirects are followed. |
| 124 | </dl> |
| 125 | |
| 126 | <P> |
jcgregorio | 87eee73 | 2007-03-09 03:23:11 +0000 | [diff] [blame^] | 127 | <dl><dt><b><tt id='l2h-19' xml:id='l2h-19' class="member">force_exception_to_status_code</tt></b></dt> |
jcgregorio | cde4f09 | 2007-03-08 21:59:04 +0000 | [diff] [blame] | 128 | <dd> |
| 129 | If <code>True</code>, which is the default, then no <tt class="module">httplib2</tt> exceptions will be thrown. Instead, |
| 130 | those error conditions will be turned into <tt class="class">Response</tt> objects |
| 131 | that will be returned normally. |
| 132 | |
| 133 | <P> |
| 134 | If <code>False</code>, then exceptions will be thrown. |
| 135 | </dl> |
| 136 | |
| 137 | <P> |
jcgregorio | 87eee73 | 2007-03-09 03:23:11 +0000 | [diff] [blame^] | 138 | <dl><dt><b><tt id='l2h-20' xml:id='l2h-20' class="member">ignore_etag</tt></b></dt> |
jcgregorio | f76c951 | 2006-11-07 18:01:50 +0000 | [diff] [blame] | 139 | <dd> |
jcgregorio | 87eee73 | 2007-03-09 03:23:11 +0000 | [diff] [blame^] | 140 | Defaults to <code>False</code>. If <code>True</code>, then any etags present in the cached response |
| 141 | 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] | 142 | 'if-match' for PUT or 'if-none-match' when GET or HEAD requests are made. This |
| 143 | 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] | 144 | </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 /> |
jcgregorio | cde4f09 | 2007-03-08 21:59:04 +0000 | [diff] [blame] | 181 | <span class="release-info">Release 0.3, documentation updated on Mar 8, 2007.</span> |
jcgregorio | 26c0cd7 | 2006-07-03 17:36:17 +0000 | [diff] [blame] | 182 | </DIV> |
| 183 | <!--End of Navigation Panel--> |
| 184 | |
| 185 | </BODY> |
| 186 | </HTML> |