1 from _typeshed.wsgi import InputStream, WSGIEnvironment
2 from datetime import datetime, timedelta
3 from typing import Any, Callable, Iterable, Iterator, Mapping, MutableMapping, Sequence, Text, Type, TypeVar, overload
4 from typing_extensions import Literal
6 from .datastructures import (
15 ImmutableTypeConversionDict,
20 from .useragents import UserAgent
25 max_content_length: int | None
26 max_form_memory_size: int
27 parameter_storage_class: Type[Any]
28 list_storage_class: Type[Any]
29 dict_storage_class: Type[Any]
30 form_data_parser_class: Type[Any]
31 trusted_hosts: Sequence[Text] | None
32 disable_data_descriptor: Any
33 environ: WSGIEnvironment = ...
35 def __init__(self, environ: WSGIEnvironment, populate_request: bool = ..., shallow: bool = ...) -> None: ...
37 def url_charset(self) -> str: ...
39 def from_values(cls, *args, **kwargs) -> BaseRequest: ...
41 def application(cls, f): ...
43 def want_form_data_parsed(self): ...
44 def make_form_data_parser(self): ...
45 def close(self) -> None: ...
46 def __enter__(self): ...
47 def __exit__(self, exc_type, exc_value, tb): ...
49 def stream(self) -> InputStream: ...
50 input_stream: InputStream
51 args: ImmutableMultiDict[Any, Any]
53 def data(self) -> bytes: ...
55 def get_data(self, cache: bool = ..., as_text: Literal[False] = ..., parse_form_data: bool = ...) -> bytes: ...
57 def get_data(self, cache: bool, as_text: Literal[True], parse_form_data: bool = ...) -> Text: ...
59 def get_data(self, *, as_text: Literal[True], parse_form_data: bool = ...) -> Text: ...
61 def get_data(self, cache: bool, as_text: bool, parse_form_data: bool = ...) -> Any: ...
63 def get_data(self, *, as_text: bool, parse_form_data: bool = ...) -> Any: ...
64 form: ImmutableMultiDict[Any, Any]
65 values: CombinedMultiDict[Any, Any]
66 files: MultiDict[Any, Any]
68 def cookies(self) -> ImmutableTypeConversionDict[str, str]: ...
69 headers: EnvironHeaders
81 def access_route(self) -> Sequence[str]: ...
83 def remote_addr(self) -> str: ...
92 _OnCloseT = TypeVar("_OnCloseT", bound=Callable[[], Any])
93 _SelfT = TypeVar("_SelfT", bound=BaseResponse)
98 default_mimetype: str | None
99 implicit_sequence_conversion: bool
100 autocorrect_location_header: bool
101 automatically_set_content_length: bool
105 direct_passthrough: bool
106 response: Iterable[bytes]
109 response: str | bytes | bytearray | Iterable[str] | Iterable[bytes] | None = ...,
110 status: Text | int | None = ...,
111 headers: Headers | Mapping[Text, Text] | Sequence[tuple[Text, Text]] | None = ...,
112 mimetype: Text | None = ...,
113 content_type: Text | None = ...,
114 direct_passthrough: bool = ...,
116 def call_on_close(self, func: _OnCloseT) -> _OnCloseT: ...
118 def force_type(cls: Type[_SelfT], response: object, environ: WSGIEnvironment | None = ...) -> _SelfT: ...
120 def from_app(cls: Type[_SelfT], app: Any, environ: WSGIEnvironment, buffered: bool = ...) -> _SelfT: ...
122 def get_data(self, as_text: Literal[False] = ...) -> bytes: ...
124 def get_data(self, as_text: Literal[True]) -> Text: ...
126 def get_data(self, as_text: bool) -> Any: ...
127 def set_data(self, value: bytes | Text) -> None: ...
129 def calculate_content_length(self) -> int | None: ...
130 def make_sequence(self) -> None: ...
131 def iter_encoded(self) -> Iterator[bytes]: ...
135 value: str | bytes = ...,
136 max_age: float | timedelta | None = ...,
137 expires: int | datetime | None = ...,
139 domain: str | None = ...,
141 httponly: bool = ...,
142 samesite: str | None = ...,
144 def delete_cookie(self, key, path: str = ..., domain: Any | None = ...): ...
146 def is_streamed(self) -> bool: ...
148 def is_sequence(self) -> bool: ...
149 def close(self) -> None: ...
150 def __enter__(self): ...
151 def __exit__(self, exc_type, exc_value, tb): ...
152 # The no_etag argument if fictional, but required for compatibility with
154 def freeze(self, no_etag: bool = ...) -> None: ...
155 def get_wsgi_headers(self, environ): ...
156 def get_app_iter(self, environ): ...
157 def get_wsgi_response(self, environ): ...
158 def __call__(self, environ, start_response): ...
160 class AcceptMixin(object):
162 def accept_mimetypes(self) -> MIMEAccept: ...
164 def accept_charsets(self) -> CharsetAccept: ...
166 def accept_encodings(self) -> Accept: ...
168 def accept_languages(self) -> LanguageAccept: ...
170 class ETagRequestMixin:
172 def cache_control(self): ...
174 def if_match(self): ...
176 def if_none_match(self): ...
178 def if_modified_since(self): ...
180 def if_unmodified_since(self): ...
182 def if_range(self): ...
186 class UserAgentMixin:
188 def user_agent(self) -> UserAgent: ...
190 class AuthorizationMixin:
192 def authorization(self) -> Authorization | None: ...
194 class StreamOnlyMixin:
195 disable_data_descriptor: Any
196 want_form_data_parsed: Any
198 class ETagResponseMixin:
200 def cache_control(self): ...
202 def make_conditional(self, request_or_environ, accept_ranges: bool = ..., complete_length: Any | None = ...): ...
203 def add_etag(self, overwrite: bool = ..., weak: bool = ...): ...
204 def set_etag(self, etag, weak: bool = ...): ...
205 def get_etag(self): ...
206 def freeze(self, no_etag: bool = ...) -> None: ...
210 class ResponseStream:
214 def __init__(self, response): ...
215 def write(self, value): ...
216 def writelines(self, seq): ...
219 def isatty(self): ...
221 def encoding(self): ...
223 class ResponseStreamMixin:
225 def stream(self) -> ResponseStream: ...
227 class CommonRequestDescriptorsMixin:
229 def content_type(self) -> str | None: ...
231 def content_length(self) -> int | None: ...
233 def content_encoding(self) -> str | None: ...
235 def content_md5(self) -> str | None: ...
237 def referrer(self) -> str | None: ...
239 def date(self) -> datetime | None: ...
241 def max_forwards(self) -> int | None: ...
243 def mimetype(self) -> str: ...
245 def mimetype_params(self) -> Mapping[str, str]: ...
247 def pragma(self) -> HeaderSet: ...
249 class CommonResponseDescriptorsMixin:
250 mimetype: str | None = ...
252 def mimetype_params(self) -> MutableMapping[str, str]: ...
253 location: str | None = ...
254 age: Any = ... # get: datetime.timedelta | None
255 content_type: str | None = ...
256 content_length: int | None = ...
257 content_location: str | None = ...
258 content_encoding: str | None = ...
259 content_md5: str | None = ...
260 date: Any = ... # get: datetime.datetime | None
261 expires: Any = ... # get: datetime.datetime | None
262 last_modified: Any = ... # get: datetime.datetime | None
263 retry_after: Any = ... # get: datetime.datetime | None
264 vary: str | None = ...
265 content_language: str | None = ...
266 allow: str | None = ...
268 class WWWAuthenticateMixin:
270 def www_authenticate(self): ...
272 class Request(BaseRequest, AcceptMixin, ETagRequestMixin, UserAgentMixin, AuthorizationMixin, CommonRequestDescriptorsMixin): ...
273 class PlainRequest(StreamOnlyMixin, Request): ...
274 class Response(BaseResponse, ETagResponseMixin, ResponseStreamMixin, CommonResponseDescriptorsMixin, WWWAuthenticateMixin): ...