11.6.1 HTTPConnection Objects

##
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.

`getresponse`( | )

  Should be called after a request is sent to get the response from the server. Returns an `HTTPResponse` instance. Note: Note that you must have read the whole response before you can send a new request to the server.

`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`( | )

  Connect to the server specified when the object was created.

`close`( | )

  Close the connection to the server.

As an alternative to using the `request()` method described above, you can also send your request step by step, by using the four functions below.

`putrequest`( | request, selector[, skip_host[, skip_accept_encoding]])

  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`). To disable automatic sending of `Host:` or `Accept-Encoding:` headers (for example to accept additional content encodings), specify skip_host or skip_accept_encoding with non-False values. Changed in version 2.4: skip_accept_encoding argument added.

`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.

`send`( | data)

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