| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="lib.html" title='Python Library Reference' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='index' href='genindex.html' title='Index' /> |
| 10 | <link rel='last' href='about.html' title='About this document...' /> |
| 11 | <link rel='help' href='about.html' title='About this document...' /> |
| 12 | <link rel="next" href="opener-director-objects.html" /> |
| 13 | <link rel="prev" href="module-urllib2.html" /> |
| 14 | <link rel="parent" href="module-urllib2.html" /> |
| 15 | <link rel="next" href="opener-director-objects.html" /> |
| 16 | <meta name='aesop' content='information' /> |
| 17 | <title>11.5.1 Request Objects </title> |
| 18 | </head> |
| 19 | <body> |
| 20 | <DIV CLASS="navigation"> |
| 21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 23 | <tr> |
| 24 | <td class='online-navigation'><a rel="prev" title="11.5 urllib2 " |
| 25 | href="module-urllib2.html"><img src='../icons/previous.png' |
| 26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 27 | <td class='online-navigation'><a rel="parent" title="11.5 urllib2 " |
| 28 | href="module-urllib2.html"><img src='../icons/up.png' |
| 29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 30 | <td class='online-navigation'><a rel="next" title="11.5.2 OpenerDirector Objects" |
| 31 | href="opener-director-objects.html"><img src='../icons/next.png' |
| 32 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 33 | <td align="center" width="100%">Python Library Reference</td> |
| 34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 35 | href="contents.html"><img src='../icons/contents.png' |
| 36 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 38 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 39 | <td class='online-navigation'><a rel="index" title="Index" |
| 40 | href="genindex.html"><img src='../icons/index.png' |
| 41 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 42 | </tr></table> |
| 43 | <div class='online-navigation'> |
| 44 | <b class="navlabel">Previous:</b> |
| 45 | <a class="sectref" rel="prev" href="module-urllib2.html">11.5 urllib2 </A> |
| 46 | <b class="navlabel">Up:</b> |
| 47 | <a class="sectref" rel="parent" href="module-urllib2.html">11.5 urllib2 </A> |
| 48 | <b class="navlabel">Next:</b> |
| 49 | <a class="sectref" rel="next" href="opener-director-objects.html">11.5.2 OpenerDirector Objects</A> |
| 50 | </div> |
| 51 | <hr /></div> |
| 52 | </DIV> |
| 53 | <!--End of Navigation Panel--> |
| 54 | |
| 55 | <H2><A NAME="SECTION0013510000000000000000"></A><A NAME="request-objects"></A> |
| 56 | <BR> |
| 57 | 11.5.1 Request Objects |
| 58 | </H2> |
| 59 | |
| 60 | <P> |
| 61 | The following methods describe all of <tt class="class">Request</tt>'s public interface, |
| 62 | and so all must be overridden in subclasses. |
| 63 | |
| 64 | <P> |
| 65 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 66 | <td><nobr><b><tt id='l2h-3247' xml:id='l2h-3247' class="method">add_data</tt></b>(</nobr></td> |
| 67 | <td><var>data</var>)</td></tr></table></dt> |
| 68 | <dd> |
| 69 | Set the <tt class="class">Request</tt> data to <var>data</var>. This is ignored by all |
| 70 | handlers except HTTP handlers -- and there it should be a byte |
| 71 | string, and will change the request to be <code>POST</code> rather than |
| 72 | <code>GET</code>. |
| 73 | </dl> |
| 74 | |
| 75 | <P> |
| 76 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 77 | <td><nobr><b><tt id='l2h-3248' xml:id='l2h-3248' class="method">get_method</tt></b>(</nobr></td> |
| 78 | <td><var></var>)</td></tr></table></dt> |
| 79 | <dd> |
| 80 | Return a string indicating the HTTP request method. This is only |
| 81 | meaningful for HTTP requests, and currently always returns |
| 82 | <code>'GET'</code> or <code>'POST'</code>. |
| 83 | </dl> |
| 84 | |
| 85 | <P> |
| 86 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 87 | <td><nobr><b><tt id='l2h-3249' xml:id='l2h-3249' class="method">has_data</tt></b>(</nobr></td> |
| 88 | <td><var></var>)</td></tr></table></dt> |
| 89 | <dd> |
| 90 | Return whether the instance has a non-<code>None</code> data. |
| 91 | </dl> |
| 92 | |
| 93 | <P> |
| 94 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 95 | <td><nobr><b><tt id='l2h-3250' xml:id='l2h-3250' class="method">get_data</tt></b>(</nobr></td> |
| 96 | <td><var></var>)</td></tr></table></dt> |
| 97 | <dd> |
| 98 | Return the instance's data. |
| 99 | </dl> |
| 100 | |
| 101 | <P> |
| 102 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 103 | <td><nobr><b><tt id='l2h-3251' xml:id='l2h-3251' class="method">add_header</tt></b>(</nobr></td> |
| 104 | <td><var>key, val</var>)</td></tr></table></dt> |
| 105 | <dd> |
| 106 | Add another header to the request. Headers are currently ignored by |
| 107 | all handlers except HTTP handlers, where they are added to the list |
| 108 | of headers sent to the server. Note that there cannot be more than |
| 109 | one header with the same name, and later calls will overwrite |
| 110 | previous calls in case the <var>key</var> collides. Currently, this is |
| 111 | no loss of HTTP functionality, since all headers which have meaning |
| 112 | when used more than once have a (header-specific) way of gaining the |
| 113 | same functionality using only one header. |
| 114 | </dl> |
| 115 | |
| 116 | <P> |
| 117 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 118 | <td><nobr><b><tt id='l2h-3252' xml:id='l2h-3252' class="method">add_unredirected_header</tt></b>(</nobr></td> |
| 119 | <td><var>key, header</var>)</td></tr></table></dt> |
| 120 | <dd> |
| 121 | Add a header that will not be added to a redirected request. |
| 122 | |
| 123 | <span class="versionnote">New in version 2.4.</span> |
| 124 | |
| 125 | </dl> |
| 126 | |
| 127 | <P> |
| 128 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 129 | <td><nobr><b><tt id='l2h-3253' xml:id='l2h-3253' class="method">has_header</tt></b>(</nobr></td> |
| 130 | <td><var>header</var>)</td></tr></table></dt> |
| 131 | <dd> |
| 132 | Return whether the instance has the named header (checks both regular |
| 133 | and unredirected). |
| 134 | |
| 135 | <span class="versionnote">New in version 2.4.</span> |
| 136 | |
| 137 | </dl> |
| 138 | |
| 139 | <P> |
| 140 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 141 | <td><nobr><b><tt id='l2h-3254' xml:id='l2h-3254' class="method">get_full_url</tt></b>(</nobr></td> |
| 142 | <td><var></var>)</td></tr></table></dt> |
| 143 | <dd> |
| 144 | Return the URL given in the constructor. |
| 145 | </dl> |
| 146 | |
| 147 | <P> |
| 148 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 149 | <td><nobr><b><tt id='l2h-3255' xml:id='l2h-3255' class="method">get_type</tt></b>(</nobr></td> |
| 150 | <td><var></var>)</td></tr></table></dt> |
| 151 | <dd> |
| 152 | Return the type of the URL -- also known as the scheme. |
| 153 | </dl> |
| 154 | |
| 155 | <P> |
| 156 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 157 | <td><nobr><b><tt id='l2h-3256' xml:id='l2h-3256' class="method">get_host</tt></b>(</nobr></td> |
| 158 | <td><var></var>)</td></tr></table></dt> |
| 159 | <dd> |
| 160 | Return the host to which a connection will be made. |
| 161 | </dl> |
| 162 | |
| 163 | <P> |
| 164 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 165 | <td><nobr><b><tt id='l2h-3257' xml:id='l2h-3257' class="method">get_selector</tt></b>(</nobr></td> |
| 166 | <td><var></var>)</td></tr></table></dt> |
| 167 | <dd> |
| 168 | Return the selector -- the part of the URL that is sent to |
| 169 | the server. |
| 170 | </dl> |
| 171 | |
| 172 | <P> |
| 173 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 174 | <td><nobr><b><tt id='l2h-3258' xml:id='l2h-3258' class="method">set_proxy</tt></b>(</nobr></td> |
| 175 | <td><var>host, type</var>)</td></tr></table></dt> |
| 176 | <dd> |
| 177 | Prepare the request by connecting to a proxy server. The <var>host</var> |
| 178 | and <var>type</var> will replace those of the instance, and the instance's |
| 179 | selector will be the original URL given in the constructor. |
| 180 | </dl> |
| 181 | |
| 182 | <P> |
| 183 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 184 | <td><nobr><b><tt id='l2h-3259' xml:id='l2h-3259' class="method">get_origin_req_host</tt></b>(</nobr></td> |
| 185 | <td><var></var>)</td></tr></table></dt> |
| 186 | <dd> |
| 187 | Return the request-host of the origin transaction, as defined by |
| 188 | <a class="rfc" id='rfcref-90005' xml:id='rfcref-90005' |
| 189 | href="http://www.faqs.org/rfcs/rfc2965.html">RFC 2965</a>. See the documentation for the <tt class="class">Request</tt> |
| 190 | constructor. |
| 191 | </dl> |
| 192 | |
| 193 | <P> |
| 194 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 195 | <td><nobr><b><tt id='l2h-3260' xml:id='l2h-3260' class="method">is_unverifiable</tt></b>(</nobr></td> |
| 196 | <td><var></var>)</td></tr></table></dt> |
| 197 | <dd> |
| 198 | Return whether the request is unverifiable, as defined by RFC 2965. |
| 199 | See the documentation for the <tt class="class">Request</tt> constructor. |
| 200 | </dl> |
| 201 | |
| 202 | <P> |
| 203 | |
| 204 | <DIV CLASS="navigation"> |
| 205 | <div class='online-navigation'> |
| 206 | <p></p><hr /> |
| 207 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 208 | <tr> |
| 209 | <td class='online-navigation'><a rel="prev" title="11.5 urllib2 " |
| 210 | href="module-urllib2.html"><img src='../icons/previous.png' |
| 211 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 212 | <td class='online-navigation'><a rel="parent" title="11.5 urllib2 " |
| 213 | href="module-urllib2.html"><img src='../icons/up.png' |
| 214 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 215 | <td class='online-navigation'><a rel="next" title="11.5.2 OpenerDirector Objects" |
| 216 | href="opener-director-objects.html"><img src='../icons/next.png' |
| 217 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 218 | <td align="center" width="100%">Python Library Reference</td> |
| 219 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 220 | href="contents.html"><img src='../icons/contents.png' |
| 221 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 222 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 223 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 224 | <td class='online-navigation'><a rel="index" title="Index" |
| 225 | href="genindex.html"><img src='../icons/index.png' |
| 226 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 227 | </tr></table> |
| 228 | <div class='online-navigation'> |
| 229 | <b class="navlabel">Previous:</b> |
| 230 | <a class="sectref" rel="prev" href="module-urllib2.html">11.5 urllib2 </A> |
| 231 | <b class="navlabel">Up:</b> |
| 232 | <a class="sectref" rel="parent" href="module-urllib2.html">11.5 urllib2 </A> |
| 233 | <b class="navlabel">Next:</b> |
| 234 | <a class="sectref" rel="next" href="opener-director-objects.html">11.5.2 OpenerDirector Objects</A> |
| 235 | </div> |
| 236 | </div> |
| 237 | <hr /> |
| 238 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 239 | </DIV> |
| 240 | <!--End of Navigation Panel--> |
| 241 | <ADDRESS> |
| 242 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 243 | </ADDRESS> |
| 244 | </BODY> |
| 245 | </HTML> |