<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--Converted with LaTeX2HTML 98.2 beta6 (August 14th, 1998)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>11.3.1 HTTP Objects</TITLE>
<META NAME="description" CONTENT="11.3.1 HTTP Objects">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="lib.css">
<LINK REL="next" HREF="HTTP_Example.html">
<LINK REL="previous" HREF="module-httplib.html">
<LINK REL="up" HREF="module-httplib.html">
<LINK REL="next" HREF="HTTP_Example.html">
</HEAD>
<BODY bgcolor="#ffffff">
<div class=navigation>
<table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="HTTP_Example.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="module-httplib.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="module-httplib.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Python Library Reference</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="HTTP_Example.html">11.3.2 Example</A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="module-httplib.html">11.3 httplib  </A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="module-httplib.html">11.3 httplib  </A></span>
<br><hr></div>
<!--End of Navigation Panel-->

<H2><A NAME="SECTION0013310000000000000000">
11.3.1 HTTP Objects</A>
</H2>

<P>
<tt class=class>HTTP</tt> instances have the following methods:

<P>
<dl><dt><b><a name="l2h-1628"><tt class=method>set_debuglevel</tt></a></b> (<var>level</var>)
<dd>
Set the debugging level (the amount of debugging output printed).
The default debug level is <tt>0</tt>, meaning no debugging output is
printed.
</dl>

<P>
<dl><dt><b><a name="l2h-1629"><tt class=method>connect</tt></a></b> (<var>host</var><big>[</big><var>, port</var><big>]</big>)
<dd>
Connect to the server given by <var>host</var> and <var>port</var>.  See the
intro for the default port.  This should be called directly only if
the instance was instantiated without passing a host.
</dl>

<P>
<dl><dt><b><a name="l2h-1630"><tt class=method>send</tt></a></b> (<var>data</var>)
<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>getreply()</tt> has been called.
</dl>

<P>
<dl><dt><b><a name="l2h-1631"><tt class=method>putrequest</tt></a></b> (<var>request, selector</var>)
<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
(<tt>HTTP/1.0</tt>).
</dl>

<P>
<dl><dt><b><a name="l2h-1632"><tt class=method>putheader</tt></a></b> (<var>header, argument</var><big>[</big><var>, ...</var><big>]</big>)
<dd>
Send an <span class=rfc><a name="rfcref-42299"
href="http://info.internet.isi.edu/in-notes/rfc/files/rfc822.txt">RFC 822</a></span> 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><b><a name="l2h-1633"><tt class=method>endheaders</tt></a></b> ()
<dd>
Send a blank line to the server, signalling the end of the headers.
</dl>

<P>
<dl><dt><b><a name="l2h-1634"><tt class=method>getreply</tt></a></b> ()
<dd>
Complete the request by shutting down the sending end of the socket,
read the reply from the server, and return a triple
<tt>(<var>replycode</var>, <var>message</var>, <var>headers</var>)</tt>.  Here,
<var>replycode</var> is the integer reply code from the request (e.g.,
<tt>200</tt> if the request was handled properly); <var>message</var> is the
message string corresponding to the reply code; and <var>headers</var> is
an instance of the class <tt class=class>mimetools.Message</tt> containing the
headers received from the server.  See the description of the
<tt class=module><a href="module-mimetools.html">mimetools</a></tt><a name="l2h-1636"></a> module.
</dl>

<P>
<dl><dt><b><a name="l2h-1635"><tt class=method>getfile</tt></a></b> ()
<dd>
Return a file object from which the data returned by the server can be
read, using the <tt class=method>read()</tt>, <tt class=method>readline()</tt> or
<tt class=method>readlines()</tt> methods.
</dl>

<P>
<p>
<div class=navigation><hr><table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="HTTP_Example.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="module-httplib.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="module-httplib.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Python Library Reference</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="HTTP_Example.html">11.3.2 Example</A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="module-httplib.html">11.3 httplib  </A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="module-httplib.html">11.3 httplib  </A></span>
</div>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>Send comments on this document to <a href="mailto:python-docs@python.org">python-docs@python.org</a>.
</ADDRESS>
</BODY>
</HTML>
