11.6.1 HTTPConnection Objects

HTTPConnection instances have the following methods:

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 header Content-Length is automatically set to the correct value. The headers argument should be a mapping of extra HTTP headers to send with the request.

Should be called after a request is sent to get the response from the server. Returns an HTTPResponse instance.

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

Connect to the server specified when the object was created.

Close the connection to the server.

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.1).

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.

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

See About this document... for information on suggesting changes.