11.3.1 HTTP Objects

HTTP instances have the following methods:

set_debuglevel (level)
Set the debugging level (the amount of debugging output printed). The default debug level is 0, meaning no debugging output is printed.

connect (host[, port])
Connect to the server given by host and port. See the intro for the default port. This should be called directly only if the instance was instantiated without passing a host.

send (data)
Send data to the server. This should be used directly only after the endheaders() method has been called and before getreply() has been called.

putrequest (request, selector)
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 request string, the selector string, and the HTTP version (HTTP/1.0).

putheader (header, argument[, ...])
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.

endheaders ()
Send a blank line to the server, signalling the end of the headers.

getreply ()
Complete the request by shutting down the sending end of the socket, read the reply from the server, and return a triple (replycode, message, headers). Here, replycode is the integer reply code from the request (e.g., 200 if the request was handled properly); message is the message string corresponding to the reply code; and headers is an instance of the class mimetools.Message containing the headers received from the server. See the description of the mimetools module.

getfile ()
Return a file object from which the data returned by the server can be read, using the read(), readline() or readlines() methods.


Send comments on this document to python-docs@python.org.