1from io import BytesIO 2from typing import ( 3 Any, 4 BinaryIO, 5 Dict, 6 Iterable, 7 List, 8 Mapping, 9 Optional, 10 Pattern, 11 Set, 12 Tuple, 13 Type, 14 TypeVar, 15 Union, 16 overload, 17) 18 19from django.contrib.auth.base_user import AbstractBaseUser 20from django.contrib.auth.models import AnonymousUser 21from django.contrib.sessions.backends.base import SessionBase 22from django.contrib.sites.models import Site 23from django.utils.datastructures import CaseInsensitiveMapping, ImmutableList, MultiValueDict 24 25from django.core.files import uploadedfile, uploadhandler 26from django.urls import ResolverMatch 27 28RAISE_ERROR: object = ... 29host_validation_re: Pattern = ... 30 31class UnreadablePostError(IOError): ... 32class RawPostDataException(Exception): ... 33 34UploadHandlerList = Union[List[uploadhandler.FileUploadHandler], ImmutableList[uploadhandler.FileUploadHandler]] 35 36class HttpHeaders(CaseInsensitiveMapping): 37 HTTP_PREFIX: str = ... 38 UNPREFIXED_HEADERS: Set[str] = ... 39 def __init__(self, environ: Mapping[str, Any]) -> None: ... 40 @classmethod 41 def parse_header_name(cls, header: str) -> Optional[str]: ... 42 43class HttpRequest(BytesIO): 44 GET: QueryDict = ... 45 POST: QueryDict = ... 46 COOKIES: Dict[str, str] = ... 47 META: Dict[str, Any] = ... 48 FILES: MultiValueDict[str, uploadedfile.UploadedFile] = ... 49 path: str = ... 50 path_info: str = ... 51 method: Optional[str] = ... 52 resolver_match: ResolverMatch = ... 53 content_type: Optional[str] = ... 54 content_params: Optional[Dict[str, str]] = ... 55 user: Union[AbstractBaseUser, AnonymousUser] 56 site: Site 57 session: SessionBase 58 encoding: Optional[str] = ... 59 upload_handlers: UploadHandlerList = ... 60 def __init__(self) -> None: ... 61 def get_host(self) -> str: ... 62 def get_port(self) -> str: ... 63 def get_full_path(self, force_append_slash: bool = ...) -> str: ... 64 def get_full_path_info(self, force_append_slash: bool = ...) -> str: ... 65 def get_signed_cookie( 66 self, key: str, default: Any = ..., salt: str = ..., max_age: Optional[int] = ... 67 ) -> Optional[str]: ... 68 def get_raw_uri(self) -> str: ... 69 def build_absolute_uri(self, location: Optional[str] = ...) -> str: ... 70 @property 71 def scheme(self) -> Optional[str]: ... 72 def is_secure(self) -> bool: ... 73 def is_ajax(self) -> bool: ... 74 def parse_file_upload( 75 self, META: Mapping[str, Any], post_data: BinaryIO 76 ) -> Tuple[QueryDict, MultiValueDict[str, uploadedfile.UploadedFile]]: ... 77 @property 78 def headers(self) -> HttpHeaders: ... 79 @property 80 def body(self) -> bytes: ... 81 def _load_post_and_files(self) -> None: ... 82 83_Q = TypeVar("_Q", bound="QueryDict") 84 85class QueryDict(MultiValueDict[str, str]): 86 encoding: str = ... 87 _mutable: bool = ... 88 def __init__( 89 self, query_string: Optional[Union[str, bytes]] = ..., mutable: bool = ..., encoding: Optional[str] = ... 90 ) -> None: ... 91 def setlist(self, key: str, list_: List[str]) -> None: ... 92 def setlistdefault(self, key: str, default_list: Optional[List[str]] = ...) -> List[str]: ... 93 def appendlist(self, key: str, value: str) -> None: ... 94 def urlencode(self, safe: Optional[str] = ...) -> str: ... 95 @classmethod 96 def fromkeys( 97 cls: Type[_Q], 98 iterable: Iterable[Union[bytes, str]], 99 value: Any = ..., 100 mutable: bool = ..., 101 encoding: Optional[str] = ..., 102 ) -> _Q: ... 103 104@overload 105def bytes_to_text(s: bytes, encoding: str) -> str: ... 106@overload 107def bytes_to_text(s: str, encoding: str) -> str: ... 108@overload 109def bytes_to_text(s: None, encoding: str) -> None: ... 110def split_domain_port(host: str) -> Tuple[str, str]: ... 111def validate_host(host: str, allowed_hosts: Iterable[str]) -> bool: ... 112