2 from json import JSONDecoder
3 from typing import Any, Callable, Iterator, Text, Type
5 from . import auth, cookies, exceptions, hooks, status_codes, structures, utils
6 from .cookies import RequestsCookieJar
7 from .packages.urllib3 import exceptions as urllib3_exceptions, fields, filepost, util
9 default_hooks = hooks.default_hooks
10 CaseInsensitiveDict = structures.CaseInsensitiveDict
11 HTTPBasicAuth = auth.HTTPBasicAuth
12 cookiejar_from_dict = cookies.cookiejar_from_dict
13 get_cookie_header = cookies.get_cookie_header
14 RequestField = fields.RequestField
15 encode_multipart_formdata = filepost.encode_multipart_formdata
16 parse_url = util.parse_url
17 DecodeError = urllib3_exceptions.DecodeError
18 ReadTimeoutError = urllib3_exceptions.ReadTimeoutError
19 ProtocolError = urllib3_exceptions.ProtocolError
20 LocationParseError = urllib3_exceptions.LocationParseError
21 HTTPError = exceptions.HTTPError
22 MissingSchema = exceptions.MissingSchema
23 InvalidURL = exceptions.InvalidURL
24 ChunkedEncodingError = exceptions.ChunkedEncodingError
25 ContentDecodingError = exceptions.ContentDecodingError
26 ConnectionError = exceptions.ConnectionError
27 StreamConsumedError = exceptions.StreamConsumedError
28 guess_filename = utils.guess_filename
29 get_auth_from_url = utils.get_auth_from_url
30 requote_uri = utils.requote_uri
31 stream_decode_response_unicode = utils.stream_decode_response_unicode
32 to_key_val_list = utils.to_key_val_list
33 parse_header_links = utils.parse_header_links
34 iter_slices = utils.iter_slices
35 guess_json_utf = utils.guess_json_utf
36 super_len = utils.super_len
37 to_native_string = utils.to_native_string
38 codes = status_codes.codes
41 DEFAULT_REDIRECT_LIMIT: Any
42 CONTENT_CHUNK_SIZE: Any
45 class RequestEncodingMixin:
47 def path_url(self): ...
49 class RequestHooksMixin:
50 def register_hook(self, event, hook): ...
51 def deregister_hook(self, event, hook): ...
53 class Request(RequestHooksMixin):
65 self, method=..., url=..., headers=..., files=..., data=..., params=..., auth=..., cookies=..., hooks=..., json=...
67 def prepare(self) -> PreparedRequest: ...
69 class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
70 method: str | Text | None
71 url: str | Text | None
72 headers: CaseInsensitiveDict[str]
73 body: bytes | Text | None
75 def __init__(self) -> None: ...
77 self, method=..., url=..., headers=..., files=..., data=..., params=..., auth=..., cookies=..., hooks=..., json=...
79 def copy(self) -> PreparedRequest: ...
80 def prepare_method(self, method) -> None: ...
81 def prepare_url(self, url, params) -> None: ...
82 def prepare_headers(self, headers) -> None: ...
83 def prepare_body(self, data, files, json=...) -> None: ...
84 def prepare_content_length(self, body) -> None: ...
85 def prepare_auth(self, auth, url=...) -> None: ...
86 def prepare_cookies(self, cookies) -> None: ...
87 def prepare_hooks(self, hooks) -> None: ...
91 _content: bytes | None # undocumented
93 headers: CaseInsensitiveDict[str]
97 history: list[Response]
99 cookies: RequestsCookieJar
100 elapsed: datetime.timedelta
101 request: PreparedRequest
102 def __init__(self) -> None: ...
103 def __bool__(self) -> bool: ...
104 def __nonzero__(self) -> bool: ...
105 def __iter__(self) -> Iterator[bytes]: ...
106 def __enter__(self) -> Response: ...
107 def __exit__(self, *args: Any) -> None: ...
109 def next(self) -> PreparedRequest | None: ...
111 def ok(self) -> bool: ...
113 def is_redirect(self) -> bool: ...
115 def is_permanent_redirect(self) -> bool: ...
117 def apparent_encoding(self) -> str: ...
118 def iter_content(self, chunk_size: int | None = ..., decode_unicode: bool = ...) -> Iterator[Any]: ...
120 self, chunk_size: int | None = ..., decode_unicode: bool = ..., delimiter: Text | bytes | None = ...
121 ) -> Iterator[Any]: ...
123 def content(self) -> bytes: ...
125 def text(self) -> str: ...
129 cls: Type[JSONDecoder] | None = ...,
130 object_hook: Callable[[dict[Any, Any]], Any] | None = ...,
131 parse_float: Callable[[str], Any] | None = ...,
132 parse_int: Callable[[str], Any] | None = ...,
133 parse_constant: Callable[[str], Any] | None = ...,
134 object_pairs_hook: Callable[[list[tuple[Any, Any]]], Any] | None = ...,
138 def links(self) -> dict[Any, Any]: ...
139 def raise_for_status(self) -> None: ...
140 def close(self) -> None: ...