E.2. httplib Module Functions and Variables

This module defines classes that implement the client side of the HTTP and HTTPS protocols. It is normally not used directly—the module urllib uses it to handle URLs that use HTTP and HTTPS.

SyntaxDescription
CLASS httpConnection(host[,port])An instance of this class represents one transaction to the HTTP server. If port is not provided and host is of the form host::port, the port to connect to is taken from this string. If host does not contain this port section and the port parameter is not provided, the connection is made to the default HTTP port, usually 80.
request(method,url[,body[,headers]])This will send a request to the server using the HTTP request method method and the selector url. If the body argument is present, it should be a string of data to send after the headers are finished. The headers argument should be a mapping of extra HTTP headers to send with the request.
get_response()Should be called after a request is sent to get the response from the server. Returns an HTTPResponse instance.
set_debuglevel(level)Sets the default debugging level; defaults to no debugging data printing out.
connect()Connects to the server specified when the object was created.
close()Closes the connection to the server.
send(data)Sends specified data to the server. This method should be called directly only after the endheaders() method and before the getreply() method.
putrequest(request,selector[,skip_host[,skip_accept_encoding]])First call made ...

Get Web Standards Programmer's Reference: HTML, CSS, JavaScript®, Perl, Python®, and PHP now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.