def rawResponse(self):
"""Return the final contents of the response.
Don't invoke this method until after deliver().
Returns a dictionary representing the response containing only
strings, numbers, lists, tuples, etc. with no backreferences.
That means you don't need any special imports to examine the contents
and you can marshal it. Currently there are two keys. 'headers' is
list of tuples each of which contains two strings: the header and
it's value. 'contents' is a string (that may be binary, for example,
if an image were being returned).
"""
headers = []
for key, value in self._headers.items():
headers.append((key, value))
for cookie in self._cookies.values():
headers.append(('Set-Cookie', cookie.headerValue()))
return dict(headers=headers, contents=self._strmOut.buffer())
评论列表
文章目录