httplib :: HTTPConnection :: Class HTTPConnection
[hide private]
[frames] | no frames]

Class HTTPConnection

Nested Classes [hide private]
  response_class
Instance Methods [hide private]
 
__init__(self, host, port=None, strict=None, timeout=<object object at 0xf74fd4e0>, source_address=None)
 
_get_hostport(self, host, port)
 
_output(self, s)
Add a line of output to the current request buffer.
 
_send_output(self, message_body=None)
Send the currently buffered request and clear the buffer.
 
_send_request(self, method, url, body, headers)
 
_set_content_length(self, body)
 
_tunnel(self)
 
close(self)
Close the connection to the HTTP server.
 
connect(self)
Connect to the host and port specified in __init__.
 
endheaders(self, message_body=None)
Indicate that the last header line has been sent to the server.
 
getresponse(self, buffering=False)
Get the response from the server.
 
putheader(self, header, *values)
Send a request header line to the server.
 
putrequest(self, method, url, skip_host=0, skip_accept_encoding=0)
Send a request to the server.
 
request(self, method, url, body=None, headers={})
Send a complete request to the server.
 
send(self, data)
Send `data' to the server.
 
set_debuglevel(self, level)
 
set_tunnel(self, host, port=None, headers=None)
Set up host and port for HTTP CONNECT tunnelling.
Class Variables [hide private]
  _http_vsn = 11
  _http_vsn_str = 'HTTP/1.1'
  auto_open = 1
  debuglevel = 0
  default_port = 80
  strict = 0
Method Details [hide private]

_output(self, s)

 

Add a line of output to the current request buffer.

Assumes that the line does *not* end with \r\n.

_send_output(self, message_body=None)

 

Send the currently buffered request and clear the buffer.

Appends an extra \r\n to the buffer. A message_body may be specified, to be appended to the request.

endheaders(self, message_body=None)

 

Indicate that the last header line has been sent to the server.

This method sends the request to the server. The optional message_body argument can be used to pass a message body associated with the request. The message body will be sent in the same packet as the message headers if it is string, otherwise it is sent as a separate packet.

putheader(self, header, *values)

 

Send a request header line to the server.

For example: h.putheader('Accept', 'text/html')

putrequest(self, method, url, skip_host=0, skip_accept_encoding=0)

 
Send a request to the server.

`method' specifies an HTTP request method, e.g. 'GET'.
`url' specifies the object being requested, e.g. '/index.html'.
`skip_host' if True does not add automatically a 'Host:' header
`skip_accept_encoding' if True does not add automatically an
   'Accept-Encoding:' header

set_tunnel(self, host, port=None, headers=None)

 

Set up host and port for HTTP CONNECT tunnelling.

In a connection that uses HTTP Connect tunneling, the host passed to the constructor is used as proxy server that relays all communication to the endpoint passed to set_tunnel. This is done by sending a HTTP CONNECT request to the proxy server when the connection is established.

This method must be called before the HTML connection has been established.

The headers argument should be a mapping of extra HTTP headers to send with the CONNECT request.