-
-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathwreq.py
More file actions
1669 lines (1307 loc) · 37 KB
/
wreq.py
File metadata and controls
1669 lines (1307 loc) · 37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import datetime
from enum import Enum, auto
from ipaddress import IPv4Address, IPv6Address
from pathlib import Path
from typing import (
Any,
AsyncGenerator,
Mapping,
Generator,
NotRequired,
Sequence,
Mapping,
Tuple,
TypedDict,
Unpack,
final,
)
from . import redirect
from .cookie import *
from .dns import ResolverOptions
from .emulation import *
from .header import *
from .http1 import Http1Options
from .http2 import Http2Options
from .proxy import *
from .redirect import History
from .tls import *
@final
class Method(Enum):
r"""
An HTTP method.
"""
GET = auto()
HEAD = auto()
POST = auto()
PUT = auto()
DELETE = auto()
OPTIONS = auto()
TRACE = auto()
PATCH = auto()
@final
class Version(Enum):
r"""
An HTTP version.
"""
HTTP_09 = auto()
HTTP_10 = auto()
HTTP_11 = auto()
HTTP_2 = auto()
HTTP_3 = auto()
@final
class StatusCode:
r"""
HTTP status code.
"""
def as_int(self) -> int:
r"""
Return the status code as an integer.
"""
...
def is_informational(self) -> bool:
r"""
Check if status is within 100-199.
"""
...
def is_success(self) -> bool:
r"""
Check if status is within 200-299.
"""
...
def is_redirection(self) -> bool:
r"""
Check if status is within 300-399.
"""
...
def is_client_error(self) -> bool:
r"""
Check if status is within 400-499.
"""
...
def is_server_error(self) -> bool:
r"""
Check if status is within 500-599.
"""
...
def __str__(self) -> str: ...
def __richcmp__(self, other: Any, op: int) -> bool: ...
@final
class SocketAddr:
r"""
A IP socket address.
"""
def __str__(self) -> str: ...
def ip(self) -> IPv4Address | IPv6Address:
r"""
Returns the IP address of the socket address.
"""
...
def port(self) -> int:
r"""
Returns the port number of the socket address.
"""
...
@final
class Multipart:
r"""
A multipart form for a request.
"""
def __init__(self, *parts: "Part") -> None:
r"""
Creates a new multipart form.
"""
...
@final
class Part:
r"""
A part of a multipart form.
"""
def __init__(
self,
name: str,
value: (
str
| bytes
| Path
| Generator[bytes, str, None]
| AsyncGenerator[bytes, str]
),
filename: str | None = None,
mime: str | None = None,
length: int | None = None,
headers: HeaderMap | None = None,
) -> None:
r"""
Creates a new part.
# Arguments
- `name` - The name of the part.
- `value` - The value of the part, either text, bytes, a file path, or a async or sync stream.
- `filename` - The filename of the part.
- `mime` - The MIME type of the part.
- `length` - The length of the part when value is a stream (e.g., for file uploads).
- `headers` - The custom headers for the part.
"""
...
class Message:
r"""
A WebSocket message.
"""
data: bytes | None
r"""
Returns the data of the message as bytes.
"""
text: str | None
r"""
Returns the text content of the message if it is a text message.
"""
binary: bytes | None
r"""
Returns the binary data of the message if it is a binary message.
"""
ping: bytes | None
r"""
Returns the ping data of the message if it is a ping message.
"""
pong: bytes | None
r"""
Returns the pong data of the message if it is a pong message.
"""
close: Tuple[int, str | None] | None
r"""
Returns the close code and reason of the message if it is a close message.
"""
json: Any
r"""
Returns the JSON representation of the message if it is a text message with JSON content.
"""
@staticmethod
def from_binary(data: bytes | Any) -> "Message":
r"""
Creates a new binary message.
# Arguments
* `data` - The binary data or any JSON-serializable data of the message.
"""
...
@staticmethod
def from_text(data: str | Any) -> "Message":
r"""
Creates a new text message.
# Arguments
* `data` - The text content or any JSON-serializable data of the message.
"""
...
@staticmethod
def from_ping(data: bytes) -> "Message":
r"""
Creates a new ping message.
# Arguments
* `data` - The ping data of the message.
"""
...
@staticmethod
def from_pong(data: bytes) -> "Message":
r"""
Creates a new pong message.
# Arguments
* `data` - The pong data of the message.
"""
...
@staticmethod
def from_close(code: int, reason: str | None = None) -> "Message":
r"""
Creates a new close message.
# Arguments
* `code` - The close code.
* `reason` - An optional reason for closing.
"""
...
def __str__(self) -> str: ...
class Streamer:
r"""
A stream response.
An asynchronous iterator yielding data chunks (bytes) or HTTP trailers (HeaderMap) from the response stream.
Used to stream response content and receive HTTP trailers if present.
Implemented in the `stream` method of the `Response` class.
Can be used in an asynchronous for loop in Python.
When streaming a response, each iteration yields either a bytes object (for body data) or a HeaderMap (for HTTP trailers, if the server sends them).
This allows you to access HTTP/1.1 or HTTP/2 trailers in addition to the main body.
# Examples
```python
import asyncio
import wreq
from wreq import Method, Emulation, HeaderMap
async def main():
resp = await wreq.get("https://example.com/stream-with-trailers")
async with resp.stream() as streamer:
async for chunk in streamer:
if isinstance(chunk, bytes):
print("Chunk: ", chunk)
elif isinstance(chunk, HeaderMap):
print("Trailers: ", chunk)
await asyncio.sleep(0.1)
if __name__ == "__main__":
asyncio.run(main())
```
"""
def __iter__(self) -> "Streamer": ...
def __next__(self) -> bytes | HeaderMap: ...
def __enter__(self) -> Any: ...
def __exit__(self, _exc_type: Any, _exc_value: Any, _traceback: Any) -> None: ...
async def __aiter__(self) -> "Streamer": ...
async def __anext__(self) -> bytes | HeaderMap: ...
async def __aenter__(self) -> Any: ...
async def __aexit__(
self, _exc_type: Any, _exc_value: Any, _traceback: Any
) -> None: ...
class Response:
r"""
A response from a request.
# Examples
```python
import asyncio
import wreq
async def main():
response = await wreq.get("https://www.rust-lang.org")
print("Status Code: ", response.status)
print("Version: ", response.version)
print("Response URL: ", response.url)
print("Headers: ", response.headers)
print("Content-Length: ", response.content_length)
print("Encoding: ", response.encoding)
print("Remote Address: ", response.remote_addr)
text_content = await response.text()
print("Text: ", text_content)
if __name__ == "__main__":
asyncio.run(main())
```
"""
url: str
r"""
Get the URL of the response.
"""
status: StatusCode
r"""
Get the status code of the response.
"""
version: Version
r"""
Get the HTTP version of the response.
"""
headers: HeaderMap
r"""
Get the headers of the response.
"""
cookies: Sequence[Cookie]
r"""
Get the cookies of the response.
"""
content_length: int | None
r"""
Get the content length of the response.
"""
remote_addr: SocketAddr | None
r"""
Get the remote address of the response.
"""
local_addr: SocketAddr | None
r"""
Get the local address of the response.
"""
history: Sequence[History]
r"""
Get the redirect history of the Response.
"""
tls_info: TlsInfo | None
r"""
Get the TLS information of the response.
"""
def raise_for_status(self) -> None:
r"""
Turn a response into an error if the server returned an error.
"""
def stream(self) -> Streamer:
r"""
Get the response into a `Streamer` of `bytes` from the body.
"""
...
async def text(self, encoding: str | None = None) -> str:
r"""
Get the text content with the response encoding, defaulting to utf-8 when unspecified.
"""
...
async def json(self) -> Any:
r"""
Get the JSON content of the response.
"""
async def bytes(self) -> bytes:
r"""
Get the bytes content of the response.
"""
...
async def close(self) -> None:
r"""
Close the response.
**Current behavior:**
- When connection pooling is **disabled**: This method closes the network connection.
- When connection pooling is **enabled**: This method closes the response, prevents further body reads,
and returns the connection to the pool for reuse.
**Future changes:**
In future versions, this method will be changed to always close the network connection regardless of
whether connection pooling is enabled or not.
**Recommendation:**
It is **not recommended** to manually call this method at present. Instead, use context managers
(async with statement) to properly manage response lifecycle. Wait for the improved implementation
in future versions.
"""
async def __aenter__(self) -> Any: ...
async def __aexit__(
self, _exc_type: Any, _exc_value: Any, _traceback: Any
) -> Any: ...
def __str__(self) -> str: ...
class WebSocket:
r"""
A WebSocket response.
"""
status: StatusCode
r"""
Get the status code of the response.
"""
version: Version
r"""
Get the HTTP version of the response.
"""
headers: HeaderMap
r"""
Get the headers of the response.
"""
cookies: Sequence[Cookie]
r"""
Get the cookies of the response.
"""
remote_addr: SocketAddr | None
r"""
Get the remote address of the response.
"""
local_addr: SocketAddr | None
r"""
Get the local address of the response.
"""
protocol: str | None
r"""
Get the WebSocket protocol.
"""
async def recv(self, timeout: datetime.timedelta | None = None) -> Message | None:
r"""
Receive a message from the WebSocket.
"""
async def send(self, message: Message) -> None:
r"""
Send a message to the WebSocket.
"""
async def send_all(self, messages: Sequence[Message]) -> None:
r"""
Send multiple messages to the WebSocket.
"""
async def close(
self,
code: int | None = None,
reason: str | None = None,
) -> None:
r"""
Close the WebSocket connection.
"""
def __aenter__(self) -> Any: ...
def __aexit__(self, _exc_type: Any, _exc_value: Any, _traceback: Any) -> Any: ...
def __str__(self) -> str: ...
class ClientConfig(TypedDict):
emulation: NotRequired[Emulation | EmulationOption]
"""Emulation config."""
user_agent: NotRequired[str]
"""
Sets the `User-Agent` header to be used by this client.
"""
headers: NotRequired[Mapping[str, str] | HeaderMap]
"""
Sets the default headers for every request.
"""
orig_headers: NotRequired[Sequence[str] | OrigHeaderMap]
"""
Sets the original headers for every request.
"""
referer: NotRequired[bool]
"""
Enable or disable automatic setting of the `Referer` header.
"""
redirect: NotRequired[redirect.Policy]
"""
Set a `redirect.Policy` for this client.
"""
cookie_store: NotRequired[bool]
"""
Enable a persistent cookie store for the client.
"""
cookie_provider: NotRequired[Jar]
"""
Set the persistent cookie store for the client.
Cookies received in responses will be passed to this store, and
additional requests will query this store for cookies.
By default, no cookie store is used.
"""
# ========= Timeout options ========
timeout: NotRequired[datetime.timedelta]
"""
Enables a request timeout.
The timeout is applied from when the request starts connecting until the
response body has finished.
Default is no timeout.
"""
connect_timeout: NotRequired[datetime.timedelta]
"""
Set a timeout for only the connect phase of a `Client`.
"""
read_timeout: NotRequired[datetime.timedelta]
"""
Set a timeout for only the read phase of a `Client`.
"""
# ======== TCP options ========
tcp_keepalive: NotRequired[datetime.timedelta]
"""
Set that all sockets have `SO_KEEPALIVE` set with the supplied duration.
Default is 15 seconds.
"""
tcp_keepalive_interval: NotRequired[datetime.timedelta]
"""
Set that all sockets have `SO_KEEPALIVE` set with the supplied interval.
Default is 15 seconds.
"""
tcp_keepalive_retries: NotRequired[int]
"""
Set that all sockets have `SO_KEEPALIVE` set with the supplied retry count.
Default is 3 retries.
"""
tcp_user_timeout: NotRequired[datetime.timedelta]
"""
Set that all sockets have `TCP_USER_TIMEOUT` set with the supplied duration.
This option controls how long transmitted data may remain unacknowledged before
the connection is force-closed.
Default is 30 seconds.
"""
tcp_nodelay: NotRequired[bool]
"""
Set whether sockets have `TCP_NODELAY` enabled.
Default is `True`.
"""
tcp_reuse_address: NotRequired[bool]
"""
Enable SO_REUSEADDR.
"""
# ======== Connection pool options ========
pool_idle_timeout: NotRequired[datetime.timedelta]
"""
Set an optional timeout for idle sockets being kept-alive.
"""
pool_max_idle_per_host: NotRequired[int]
"""
Sets the maximum idle connection per host allowed in the pool.
"""
pool_max_size: NotRequired[int]
"""
Sets the maximum number of connections in the pool.
"""
# ======== HTTP options ========
http1_only: NotRequired[bool]
"""
Only use HTTP/1.
"""
http2_only: NotRequired[bool]
"""
Only use HTTP/2.
"""
https_only: NotRequired[bool]
"""
Restrict the Client to be used with HTTPS only requests.
"""
http1_options: NotRequired[Http1Options]
"""
Sets the HTTP/1 options for the client.
"""
http2_options: NotRequired[Http2Options]
"""
Sets the HTTP/2 options for the client.
"""
# ======== TLS options ========
tls_verify: NotRequired[bool | Path | CertStore]
"""
Sets whether to verify TLS certificates.
"""
tls_verify_hostname: NotRequired[bool]
"""
Configures the use of hostname verification when connecting.
"""
tls_identity: NotRequired[Identity]
"""
Represents a private key and X509 cert as a client certificate.
"""
tls_keylog: NotRequired[KeyLog]
"""
Key logging policy (environment or file).
"""
tls_info: NotRequired[bool]
"""
Add TLS information as `TlsInfo` extension to responses.
"""
tls_min_version: NotRequired[TlsVersion]
"""
Minimum TLS version.
"""
tls_max_version: NotRequired[TlsVersion]
"""
Maximum TLS version.
"""
tls_options: NotRequired[TlsOptions]
"""
Sets the TLS options.
"""
# ======== Network options ========
no_proxy: NotRequired[bool]
"""
Clear all `proxies`, so `Client` will use no proxy anymore.
This also disables the automatic usage of the "system" proxy.
"""
proxies: NotRequired[Sequence[Proxy]]
"""
Add a `Proxy` list to the client.
"""
local_address: NotRequired[IPv4Address | IPv6Address]
"""
Bind to a local IP Address.
"""
local_addresses: NotRequired[Tuple[IPv4Address | None, IPv6Address | None]]
"""
Bind to dual-stack local IP Addresses.
"""
interface: NotRequired[str]
"""
Bind connections only on the specified network interface.
This option is only available on the following operating systems:
- Android
- Fuchsia
- Linux
- macOS and macOS-like systems (iOS, tvOS, watchOS and visionOS)
- Solaris and illumos
On Android, Linux, and Fuchsia, this uses the
[`SO_BINDTODEVICE`][man-7-socket] socket option. On macOS and macOS-like
systems, Solaris, and illumos, this instead uses the [`IP_BOUND_IF` and
`IPV6_BOUND_IF`][man-7p-ip] socket options (as appropriate).
Note that connections will fail if the provided interface name is not a
network interface that currently exists when a connection is established.
[man-7-socket]: https://man7.org/linux/man-pages/man7/socket.7.html
[man-7p-ip]: https://docs.oracle.com/cd/E86824_01/html/E54777/ip-7p.html
"""
# ========= DNS options =========
dns_options: NotRequired[ResolverOptions]
# ========= Compression options =========
gzip: NotRequired[bool]
"""
Enable auto gzip decompression by checking the `Content-Encoding` response header.
"""
brotli: NotRequired[bool]
"""
Enable auto brotli decompression by checking the `Content-Encoding` response header.
"""
deflate: NotRequired[bool]
"""
Enable auto deflate decompression by checking the `Content-Encoding` response header.
"""
zstd: NotRequired[bool]
"""
Enable auto zstd decompression by checking the `Content-Encoding` response header.
"""
class Request(TypedDict):
emulation: NotRequired[Emulation | EmulationOption]
"""
The Emulation settings for the request.
"""
headers: NotRequired[Mapping[str, str] | HeaderMap]
"""
The headers to use for the request.
"""
orig_headers: NotRequired[Sequence[str] | OrigHeaderMap]
"""
The original headers to use for the request.
"""
default_headers: NotRequired[bool]
"""
The option enables default headers.
"""
cookies: NotRequired[str | Mapping[str, str]]
"""
The cookies to use for the request.
"""
proxy: NotRequired[Proxy]
"""
The proxy to use for the request.
"""
local_address: NotRequired[IPv4Address | IPv6Address]
"""
Bind to a local IP Address.
"""
local_addresses: NotRequired[Tuple[IPv4Address | None, IPv6Address | None]]
"""
Bind to dual-stack local IP Addresses.
"""
interface: NotRequired[str]
"""
Bind connections only on the specified network interface.
This option is only available on the following operating systems:
- Android
- Fuchsia
- Linux
- macOS and macOS-like systems (iOS, tvOS, watchOS and visionOS)
- Solaris and illumos
On Android, Linux, and Fuchsia, this uses the
[`SO_BINDTODEVICE`][man-7-socket] socket option. On macOS and macOS-like
systems, Solaris, and illumos, this instead uses the [`IP_BOUND_IF` and
`IPV6_BOUND_IF`][man-7p-ip] socket options (as appropriate).
Note that connections will fail if the provided interface name is not a
network interface that currently exists when a connection is established.
[man-7-socket]: https://man7.org/linux/man-pages/man7/socket.7.html
[man-7p-ip]: https://docs.oracle.com/cd/E86824_01/html/E54777/ip-7p.html
"""
timeout: NotRequired[datetime.timedelta]
"""
The timeout to use for the request.
"""
read_timeout: NotRequired[datetime.timedelta]
"""
The read timeout to use for the request.
"""
version: NotRequired[Version]
"""
The HTTP version to use for the request.
"""
redirect: NotRequired[redirect.Policy]
"""
The redirect policy.
"""
cookie_provider: NotRequired[Jar]
"""
Set cookie provider for the request.
"""
gzip: NotRequired[bool]
"""
Sets gzip as an accepted encoding.
"""
brotli: NotRequired[bool]
"""
Sets brotli as an accepted encoding.
"""
deflate: NotRequired[bool]
"""
Sets deflate as an accepted encoding.
"""
zstd: NotRequired[bool]
"""
Sets zstd as an accepted encoding.
"""
auth: NotRequired[str]
"""
The authentication to use for the request.
"""
bearer_auth: NotRequired[str]
"""
The bearer authentication to use for the request.
"""
basic_auth: NotRequired[Tuple[str, str | None]]
"""
The basic authentication to use for the request.
"""
query: NotRequired[
Sequence[Tuple[str, str | int | float | bool]]
| Mapping[str, str | int | float | bool]
]
"""
The query parameters to use for the request.
"""
form: NotRequired[
Sequence[Tuple[str, str | int | float | bool]]
| Mapping[str, str | int | float | bool]
]
"""
The form parameters to use for the request.
"""
json: NotRequired[Any]
"""
The JSON body to use for the request.
"""
body: NotRequired[
str
| bytes
| Sequence[Tuple[str, str]]
| Tuple[str, str | int | float | bool]
| Mapping[str, str | int | float | bool]
| Any
| Generator[bytes, str, None]
| AsyncGenerator[bytes, str]
]
"""
The body to use for the request.
"""
multipart: NotRequired[Multipart]
"""
The multipart form to use for the request.
"""
class WebSocketRequest(TypedDict):
emulation: NotRequired[Emulation | EmulationOption]
"""
The Emulation settings for the request.
"""
proxy: NotRequired[Proxy]
"""
The proxy to use for the request.
"""
local_address: NotRequired[IPv4Address | IPv6Address]
"""
Bind to a local IP Address.
"""
local_addresses: NotRequired[Tuple[IPv4Address | None, IPv6Address | None]]
"""
Bind to dual-stack local IP Addresses.
"""
interface: NotRequired[str]
"""
Bind to an interface by SO_BINDTODEVICE.
"""
headers: NotRequired[Mapping[str, str] | HeaderMap]
"""
The headers to use for the request.
"""
orig_headers: NotRequired[Sequence[str] | OrigHeaderMap]
"""
The original headers to use for the request.
"""
default_headers: NotRequired[bool]
"""
The option enables default headers.
"""
cookies: NotRequired[str | Mapping[str, str]]