Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / html / python / lib / httpconnection-objects.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="httpresponse-objects.html" />
<link rel="prev" href="module-httplib.html" />
<link rel="parent" href="module-httplib.html" />
<link rel="next" href="httpresponse-objects.html" />
<meta name='aesop' content='information' />
<title>11.6.1 HTTPConnection Objects </title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="11.6 httplib "
href="module-httplib.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="11.6 httplib "
href="module-httplib.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="11.6.2 HTTPResponse Objects"
href="httpresponse-objects.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-httplib.html">11.6 httplib </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-httplib.html">11.6 httplib </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="httpresponse-objects.html">11.6.2 HTTPResponse Objects</A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION0013610000000000000000"></A><A NAME="httpconnection-objects"></A>
<BR>
11.6.1 HTTPConnection Objects
</H2>
<P>
<tt class="class">HTTPConnection</tt> instances have the following methods:
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-3316' xml:id='l2h-3316' class="method">request</tt></b>(</nobr></td>
<td><var>method, url</var><big>[</big><var>, body</var><big>[</big><var>, headers</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This will send a request to the server using the HTTP request method
<var>method</var> and the selector <var>url</var>. If the <var>body</var> argument is
present, it should be a string of data to send after the headers are finished.
The header Content-Length is automatically set to the correct value.
The <var>headers</var> argument should be a mapping of extra HTTP headers to send
with the request.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-3317' xml:id='l2h-3317' class="method">getresponse</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Should be called after a request is sent to get the response from the server.
Returns an <tt class="class">HTTPResponse</tt> instance.
<span class="note"><b class="label">Note:</b>
Note that you must have read the whole response before you can send a new
request to the server.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-3318' xml:id='l2h-3318' class="method">set_debuglevel</tt></b>(</nobr></td>
<td><var>level</var>)</td></tr></table></dt>
<dd>
Set the debugging level (the amount of debugging output printed).
The default debug level is <code>0</code>, meaning no debugging output is
printed.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-3319' xml:id='l2h-3319' class="method">connect</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Connect to the server specified when the object was created.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-3320' xml:id='l2h-3320' class="method">close</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Close the connection to the server.
</dl>
<P>
As an alternative to using the <tt class="method">request()</tt> method described above,
you can also send your request step by step, by using the four functions
below.
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-3321' xml:id='l2h-3321' class="method">putrequest</tt></b>(</nobr></td>
<td><var>request, selector</var><big>[</big><var>,
skip_host</var><big>[</big><var>, skip_accept_encoding</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This should be the first call after the connection to the server has
been made. It sends a line to the server consisting of the
<var>request</var> string, the <var>selector</var> string, and the HTTP version
(<code>HTTP/1.1</code>). To disable automatic sending of <code>Host:</code> or
<code>Accept-Encoding:</code> headers (for example to accept additional
content encodings), specify <var>skip_host</var> or <var>skip_accept_encoding</var>
with non-False values.
<span class="versionnote">Changed in version 2.4:
<var>skip_accept_encoding</var> argument added.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-3322' xml:id='l2h-3322' class="method">putheader</tt></b>(</nobr></td>
<td><var>header, argument</var><big>[</big><var>, ...</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Send an <a class="rfc" id='rfcref-90106' xml:id='rfcref-90106'
href="http://www.faqs.org/rfcs/rfc822.html">RFC 822</a>-style header to the server. It sends a line to the
server consisting of the header, a colon and a space, and the first
argument. If more arguments are given, continuation lines are sent,
each consisting of a tab and an argument.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-3323' xml:id='l2h-3323' class="method">endheaders</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Send a blank line to the server, signalling the end of the headers.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-3324' xml:id='l2h-3324' class="method">send</tt></b>(</nobr></td>
<td><var>data</var>)</td></tr></table></dt>
<dd>
Send data to the server. This should be used directly only after the
<tt class="method">endheaders()</tt> method has been called and before
<tt class="method">getresponse()</tt> is called.
</dl>
<P>
<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="11.6 httplib "
href="module-httplib.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="11.6 httplib "
href="module-httplib.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="11.6.2 HTTPResponse Objects"
href="httpresponse-objects.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-httplib.html">11.6 httplib </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-httplib.html">11.6 httplib </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="httpresponse-objects.html">11.6.2 HTTPResponse Objects</A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>