diff -r f0ca1fabb41f Doc/library/http.client.rst --- a/Doc/library/http.client.rst Tue Jun 23 20:48:52 2015 -0700 +++ b/Doc/library/http.client.rst Sat Jul 04 15:24:26 2015 +0800 @@ -217,6 +217,31 @@ HTTPConnection Objects ---------------------- + +:class:`HTTPConnection` instances have the following attributes + + +.. attribute:: HTTPConnection.response_class + + A reference to the :class:`HTTPResponse` by default. + :meth:`HTTPConnection.getresponse` returns an instance of the class referenced + by this attribute. This attribute can be changed directly. + + +.. attribute:: HTTPConnection.default_port + + Defaults to :data:`http.client.HTTP_PORT` for :class:`HTTPConnection` or + :data:`http.client.HTTPS_PORT` for :class:`HTTPSConnection`. This attribute + cannot be modified. To set a non-default port, suffix the port to the ``host`` + while initializing :class:`HTTPConnection`. + + +.. attribute:: HTTPConnection.debuglevel + + A debugging hook. If :attr:`debuglevel` is greater than zero, request and + response messages will be printed out to stdout as they are parsed. + + :class:`HTTPConnection` instances have the following methods: @@ -256,7 +281,8 @@ .. method:: HTTPConnection.getresponse() Should be called after a request is sent to get the response from the server. - Returns an :class:`HTTPResponse` instance. + Returns an :class:`HTTPResponse` instance or an instance of the class referenced + by the :attr:`response_class` attribute. .. note:: diff -r f0ca1fabb41f Lib/http/client.py --- a/Lib/http/client.py Tue Jun 23 20:48:52 2015 -0700 +++ b/Lib/http/client.py Sat Jul 04 15:24:26 2015 +0800 @@ -1131,8 +1131,9 @@ """Get the response from the server. If the HTTPConnection is in the correct state, returns an - instance of HTTPResponse or of whatever object is returned by - class the response_class variable. + instance of the class referenced by the HTTPConnection.response_class + variable. HTTPConnection.response_class variable holds the + HTTPResponse class by default. If a request has not been sent or if a previous response has not be handled, ResponseNotReady is raised. If the HTTP