PyDocs

Nav

Internet Protocols and Support

HTTPConnection

http.client

class (source) not WASI
  • HTTPConnection(host, port=None, [timeout, ]source_address=None, blocksize=8192, max_response_headers=None)
An HTTPConnection instance represents one transaction with an HTTP server. It should be instantiated by passing it a host and optional port number. If no port number is passed, the port is extracted from the host string if it has the form host:port, else the default HTTP port (80) is used. If the optional timeout parameter is given, blocking operations (like connection attempts) will timeout after that many seconds (if it is not given, the global default timeout setting is used). The optional source_address parameter may be a tuple of a (host, port) to use as the source address the HTTP connection is made from. The optional blocksize parameter sets the buffer size in bytes for sending a file-like message body. The optional max_response_headers parameter sets the maximum number of allowed response headers to help prevent denial-of-service attacks, otherwise the default value (100) is used.
Changed in 3.2, 3.4, 3.7, 3.15
  • 3.2: source_address was added.
  • 3.4: The strict parameter was removed. HTTP 0.9-style “Simple Responses” are no longer supported.
  • 3.7: blocksize parameter was added.
  • 3.15: max_response_headers parameter was added.
Members of HTTPConnection

b

blocksize
Buffer size in bytes for sending a file-like message body.

c

close
Close the connection to the HTTP server.
connect
Connect to the host and port specified in __init__.

e

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

g

get_proxy_response_headers
Returns a dictionary with the headers of the response received from the proxy server to the CONNECT request sent to set the tunnel.
getresponse
Get the response from the server.

m

max_response_headers
The maximum number of allowed response headers to help prevent denial-of-service attacks.

p

putheader
Send a request header line to the server.
putrequest
Send a request to the server.

r

request
Send a complete request to the server.

s

send
Send 'data' to the server.
set_debuglevel
Set the debugging level.
set_tunnel
Set up host and port for HTTP CONNECT tunnelling.
1 Example
>>> h1 = http.client.HTTPConnection('www.python.org')
>>> h2 = http.client.HTTPConnection('www.python.org:80')
>>> h3 = http.client.HTTPConnection('www.python.org', 80)
>>> h4 = http.client.HTTPConnection('www.python.org', 80, timeout=10)
from the Python docs
See Also
No see-alsos for http.client/HTTPConnection
0 Notes
No notes for HTTPConnection