fix: add headers to http.HttpResponseBase constructor (#564)

* fix: add headers to http.HttpResponseBase constructor

fixes #563

* fix: correct Dict() with Dict[]

* feat: add ResponseHeaders typing

* fix: correct HttpResponseBase.headers type

* fix: add missing ...s

* fix: add CaseInsensitiveMapping import

* fix: make Dict -> Dict[str, str]
This commit is contained in:
Chas Nelson
2021-02-09 22:07:35 +03:00
committed by GitHub
parent 8f9e77ce39
commit e6dcfe4fc6
+12 -1
View File
@@ -6,24 +6,35 @@ from typing import Any, Dict, Iterable, Iterator, List, Optional, Tuple, Type, U
from django.core.handlers.wsgi import WSGIRequest from django.core.handlers.wsgi import WSGIRequest
from django.http.cookie import SimpleCookie from django.http.cookie import SimpleCookie
from django.test.client import Client from django.test.client import Client
from django.utils.datastructures import CaseInsensitiveMapping
from django.template import Context, Template from django.template import Context, Template
from django.urls import ResolverMatch from django.urls import ResolverMatch
class BadHeaderError(ValueError): ... class BadHeaderError(ValueError): ...
class ResponseHeaders(CaseInsensitiveMapping):
store: Dict[str, str] = ...
def __init__(self, data: Dict[str, str]) -> None: ...
def _convert_to_charset(self, value: Union[bytes, str], charset: str, mime_encode: str=...) -> str: ...
def __delitem__(self, key: str) -> None: ...
def __setitem__(self, key: str, value: str) -> None: ...
def pop(self, key: str, default: Optional[str] = ...) -> str: ...
def setdefault(self, key: str, value: str) -> None: ...
class HttpResponseBase(Iterable[Any]): class HttpResponseBase(Iterable[Any]):
status_code: int = ... status_code: int = ...
cookies: SimpleCookie = ... cookies: SimpleCookie = ...
reason_phrase: str = ... reason_phrase: str = ...
charset: str = ... charset: str = ...
closed: bool = ... closed: bool = ...
headers: ResponseHeaders = ...
def __init__( def __init__(
self, self,
content_type: Optional[str] = ..., content_type: Optional[str] = ...,
status: Optional[int] = ..., status: Optional[int] = ...,
reason: Optional[str] = ..., reason: Optional[str] = ...,
charset: Optional[str] = ..., charset: Optional[str] = ...,
headers: Optional[Dict[str, str]] = ...,
) -> None: ... ) -> None: ...
def serialize_headers(self) -> bytes: ... def serialize_headers(self) -> bytes: ...
def __setitem__(self, header: Union[str, bytes], value: Union[str, bytes, int]) -> None: ... def __setitem__(self, header: Union[str, bytes], value: Union[str, bytes, int]) -> None: ...