Name
getresponse
Synopsis
h.getresponse( )Returns an instance r of class
HTTPResponse, which represents the response
received from the HTTP server. Call after method
request has returned. Instance
r supplies the following attributes and
methods:
-
r.getheader(name,default=None) Returns the contents of header
name, ordefaultif no such header exists.-
r.msg An instance of class
Messageof modulemimetools, covered in Chapter 21. You can user.msgto access the response’s headers and body.-
r.read( ) Returns a string that is the body of the server’s response.
-
r.reason The string that the server gave as the reason for errors or anomalies. If the request was successful,
r.reasoncould, for example, be 'OK‘.-
r.status An integer, the status code that the server returned. If the request was successful,
r.statusshould be between200and299according to the HTTP standards. Values between400and599are typical error codes, again according to HTTP standards. For example,404is the error code that a server sends when the page you request cannot be found.-
r.version 10if the server supports only HTTP 1.0,11if the server supports HTTP 1.1.