mirror of
https://github.com/django/django.git
synced 2025-07-24 13:44:32 +00:00
Fixed #18523 -- Added stream-like API to HttpResponse.
Added getvalue() to HttpResponse to return the content of the response, along with a few other methods to partially match io.IOBase. Thanks Claude Paroz for the suggestion and Nick Sanford for review.
This commit is contained in:
parent
f7969b0920
commit
ebc8e79cf3
5 changed files with 93 additions and 3 deletions
|
@ -651,6 +651,12 @@ Attributes
|
|||
This attribute exists so middleware can treat streaming responses
|
||||
differently from regular responses.
|
||||
|
||||
.. attribute:: HttpResponse.closed
|
||||
|
||||
.. versionadded:: 1.8
|
||||
|
||||
``True`` if the response has been closed.
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
|
@ -769,6 +775,27 @@ Methods
|
|||
|
||||
This method makes an :class:`HttpResponse` instance a file-like object.
|
||||
|
||||
.. method:: HttpResponse.getvalue()
|
||||
|
||||
.. versionadded:: 1.8
|
||||
|
||||
Returns the value of :attr:`HttpResponse.content`. This method makes
|
||||
an :class:`HttpResponse` instance a stream-like object.
|
||||
|
||||
.. method:: HttpResponse.writable()
|
||||
|
||||
.. versionadded:: 1.8
|
||||
|
||||
Always ``True``. This method makes an :class:`HttpResponse` instance a
|
||||
stream-like object.
|
||||
|
||||
.. method:: HttpResponse.writelines(lines)
|
||||
|
||||
.. versionadded:: 1.8
|
||||
|
||||
Writes a list of lines to the response. Line seperators are not added. This
|
||||
method makes an :class:`HttpResponse` instance a stream-like object.
|
||||
|
||||
.. _HTTP status code: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10
|
||||
|
||||
.. _ref-httpresponse-subclasses:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue