home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
p
/
python
/
pyhtmldoc
/
h
/
http_objec
< prev
next >
Wrap
Text File
|
1996-11-14
|
3KB
|
54 lines
<TITLE>HTTP Objects -- Python library reference</TITLE>
Next: <A HREF="../h/http_example" TYPE="Next">HTTP Example</A>
Prev: <A HREF="../h/httplib" TYPE="Prev">httplib</A>
Up: <A HREF="../h/httplib" TYPE="Up">httplib</A>
Top: <A HREF="../t/top" TYPE="Top">Top</A>
<H2>10.3.1. HTTP Objects</H2>
<CODE>HTTP</CODE> instances have the following methods:
<P>
<DL><DT><B>set_debuglevel</B> (<VAR>level</VAR>) -- Method on HTTP<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>
<DL><DT><B>connect</B> (<VAR>host</VAR>[, <VAR>port</VAR>]) -- Method on HTTP<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>
<DL><DT><B>send</B> (<VAR>data</VAR>) -- Method on HTTP<DD>
Send data to the server. This should be used directly only after the
<CODE>endheaders()</CODE> method has been called and before
<CODE>getreply()</CODE> has been called.
</DL>
<DL><DT><B>putrequest</B> (<VAR>request</VAR>, <VAR>selector</VAR>) -- Method on HTTP<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.0</CODE>).
</DL>
<DL><DT><B>putheader</B> (<VAR>header</VAR>, <VAR>argument</VAR>[, ...]) -- Method on HTTP<DD>
Send an RFC-822 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>
<DL><DT><B>endheaders</B> () -- Method on HTTP<DD>
Send a blank line to the server, signalling the end of the headers.
</DL>
<DL><DT><B>getreply</B> () -- Method on HTTP<DD>
Complete the request by shutting down the sending end of the socket,
read the reply from the server, and return a triple (<VAR>replycode</VAR>,
<VAR>message</VAR>, <VAR>headers</VAR>). Here <VAR>replycode</VAR> is the integer
reply code from the request (e.g. <CODE>200</CODE> if the request was
handled properly); <VAR>message</VAR> is the message string corresponding
to the reply code; and <VAR>header</VAR> is an instance of the class
<CODE>rfc822.Message</CODE> containing the headers received from the server.
See the description of the <CODE>rfc822</CODE> module.
</DL>
<DL><DT><B>getfile</B> () -- Method on HTTP<DD>
Return a file object from which the data returned by the server can be
read, using the <CODE>read()</CODE>, <CODE>readline()</CODE> or <CODE>readlines()</CODE>
methods.
</DL>