PyDocs

Nav

Internet Protocols and Support

HTTPConnection.getresponse

http.client

method of HTTPConnection (source) not WASI
  • HTTPConnection.getresponse()
Get the response from the server.

If the HTTPConnection is in the correct state, returns an
instance of HTTPResponse.

If a request has not been sent or if a previous response has
not be handled, ResponseNotReady is raised.  If the HTTP
response indicates that the connection should be closed, then
it will be closed before the response is returned.  When the
connection is closed, the underlying socket is closed.
Changed in 3.5
  • 3.5: If a ConnectionError or subclass is raised, the HTTPConnection object will be ready to reconnect when a new request is sent. Note that this does not apply to OSErrors raised by the underlying socket. Instead the caller is responsible to call close() on the existing connection.
1 Example
>>> # This creates an HTTP request
>>> # with the content of BODY as the enclosed representation
>>> # for the resource http://localhost:8080/file
...
>>> import http.client
>>> BODY = "***filecontents***"
>>> conn = http.client.HTTPConnection("localhost", 8080)
>>> conn.request("PUT", "/file", BODY)
>>> response = conn.getresponse()
>>> print(response.status, response.reason)
200, OK
from the Python docs
See Also
No see-alsos for http.client/HTTPConnection.getresponse
0 Notes
No notes for HTTPConnection.getresponse