title: Sensible way to extend requests.Response Class?
body: <p>I'm trying to extend <code>requests.Response</code> but I'm not sure how to go about it. </p>
  
  <p>What I want is to extend <code>requests.Response</code>. The problem I see is that I'd have to create an entirely new fork of the library, or in the very least create a custom adapter and implement custom code for this. </p>
  
  <p>I'm currently storing the response in an attribute of my new class, but this would mean my custom <code>APIResponse</code> does not actually behave like an extended <code>requests.Response</code> object.</p>
  
  <p>This is my current dummy work around.</p>
  
  <pre><code>class APIResponse:
      def __init__(self, req_response, formatted_json=None):
          self._content = req_response._content
          self._response = req_response
  
      @property
      def response(self):
          return self._response
  </code></pre>
  
  <p>As stated above, I'd like my custom class to behave like a <code>requests.Response</code> object, with some extra features. Since the <code>Response</code> objects are generated at a very low level, namely the <code>HTTPAdapter</code> module in the <code>requests</code> library, I'd have to write a custom adapter as well - and, logically, also customize the <code>requests.Sessions</code> class, where it's called. </p>
  
  <p>Which all leads me to belive I'm missing something here. </p>
  
  <p>Is there a sensible way to extend <code>request.Response</code> objects, without substantial amounts of code?</p>
  
  <p>I have also tried 'wrapping' a class around an instantiated <code>Response</code> object, but it looks very hacky:</p>
  
  <pre><code>class APIResponse(Response):
      __attrs__ = ['_content', 'status_code', 'headers', 'url', 'history',
                   'encoding', 'reason', 'cookies', 'elapsed', 'request',
                   '_formatted']
  
      def __init__(self, req_response):
          self._content = req_response._content
          self._content_consumed = req_response._content_consumed
          self.status_code = req_response.status_code
          self.headers = req_response.headers
          self.url = req_response.url
          self.history = req_response.history
          self.encoding = req_response.encoding
          self.reason = req_response.reason
          self.cookies = req_response.cookies
          self.elapsed = req_response.elapsed
          self.request = req_response.request
  </code></pre>