#629: Add HTTP response "streaming" attribute (#632)

Add the missing attribute django.http.response.StreamingHttpResponse.streaming .

This is actually done by moving the attribute from HttpResponse to the base class HttpResponseBase.

The real Django source code declares this attribute on HttpResponse and StreamingHttpResponse, however that's only because Django doesn't have type hints.  The right place for the type hint is on the base class HttpResponseBase, since all instances of that base class are actually instances of HttpResponse or StreamingHttpResponse or a subclass of those two classes.  So it's guaranteed that every HttpResponseBase instance has the attribute.

Fixes bug #629.
This commit is contained in:
jonfoster
2021-06-03 19:25:25 +01:00
committed by GitHub
parent becb0c9605
commit 893ad6bb02

View File

@@ -23,6 +23,7 @@ class ResponseHeaders(CaseInsensitiveMapping):
class HttpResponseBase(Iterable[Any]): class HttpResponseBase(Iterable[Any]):
status_code: int = ... status_code: int = ...
streaming: bool = ...
cookies: SimpleCookie = ... cookies: SimpleCookie = ...
reason_phrase: str = ... reason_phrase: str = ...
charset: str = ... charset: str = ...
@@ -81,7 +82,6 @@ class HttpResponse(HttpResponseBase):
test_server_port: str test_server_port: str
test_was_secure_request: bool test_was_secure_request: bool
xframe_options_exempt: bool xframe_options_exempt: bool
streaming: bool = ...
def __init__(self, content: object = ..., *args: Any, **kwargs: Any) -> None: ... def __init__(self, content: object = ..., *args: Any, **kwargs: Any) -> None: ...
def serialize(self) -> bytes: ... def serialize(self) -> bytes: ...
__bytes__ = serialize __bytes__ = serialize