class documentation

class _Response(proxyForInterface(IResponse)): (source)

View In Hierarchy

A wrapper for :class:`twisted.web.iweb.IResponse` which manages cookies and adds a few convenience methods.

Method __init__ Undocumented
Method __repr__ Generate a representation of the response which includes the HTTP status code, Content-Type header, and body size, if available.
Method collect Incrementally collect the body of the response, per :func:`treq.collect()`.
Method content Read the entire body all at once, per :func:`treq.content()`.
Method cookies Get a copy of this response's cookies.
Method history Get a list of all responses that (such as intermediate redirects), that ultimately ended in the current response. The responses are ordered chronologically.
Method json Collect the response body as JSON per :func:`treq.json_content()`.
Method text Read the entire body all at once as text, per :func:`treq.text_content()`.
Instance Variable original Undocumented
Instance Variable _cookiejar Undocumented
def __init__(self, original, cookiejar): (source)

Undocumented

def __repr__(self): (source)

Generate a representation of the response which includes the HTTP status code, Content-Type header, and body size, if available.

def collect(self, collector): (source)

Incrementally collect the body of the response, per :func:`treq.collect()`. :param collector: A single argument callable that will be called with chunks of body data as it is received. :returns: A `Deferred` that fires when the entire body has been received.

def content(self): (source)

Read the entire body all at once, per :func:`treq.content()`. :returns: A `Deferred` that fires with a `bytes` object when the entire body has been received.

def cookies(self): (source)

Get a copy of this response's cookies. :rtype: :class:`requests.cookies.RequestsCookieJar`

def history(self): (source)

Get a list of all responses that (such as intermediate redirects), that ultimately ended in the current response. The responses are ordered chronologically. :returns: A `list` of :class:`~treq.response._Response` objects

def json(self, **kwargs): (source)

Collect the response body as JSON per :func:`treq.json_content()`. :param kwargs: Any keyword arguments accepted by :py:func:`json.loads` :rtype: Deferred that fires with the decoded JSON when the entire body has been read.

def text(self, encoding='ISO-8859-1'): (source)

Read the entire body all at once as text, per :func:`treq.text_content()`. :rtype: A `Deferred` that fires with a unicode string when the entire body has been received.

original = (source)

Undocumented

_cookiejar = (source)

Undocumented