pyqwest 0.3.0__cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pyqwest/_pyqwest.pyi ADDED
@@ -0,0 +1,1390 @@
1
+ import datetime
2
+ from collections.abc import (
3
+ AsyncIterator,
4
+ Awaitable,
5
+ ItemsView,
6
+ Iterable,
7
+ Iterator,
8
+ KeysView,
9
+ Mapping,
10
+ Sequence,
11
+ ValuesView,
12
+ )
13
+ from contextlib import AbstractContextManager
14
+ from types import TracebackType
15
+ from typing import Protocol, TypeAlias, TypeVar, overload, runtime_checkable
16
+
17
+ _T = TypeVar("_T")
18
+ JSON: TypeAlias = Mapping[str, JSON] | Sequence[JSON] | str | int | float | bool | None
19
+
20
+ Buffer: TypeAlias = bytes | memoryview | bytearray
21
+
22
+ class Headers:
23
+ """Container of HTTP headers.
24
+
25
+ This class behaves like a dictionary with case-insensitive keys and
26
+ string values. Standard dictionary access will act as if keys can only
27
+ have a single value. The add method can be used to It additionally can be used to store
28
+ multiple values for the same key by using the add method. Iterating over
29
+ values or items will return all values, including duplicates.
30
+ """
31
+
32
+ def __init__(
33
+ self,
34
+ items: Mapping[str | HTTPHeaderName, str]
35
+ | Iterable[tuple[str | HTTPHeaderName, str]]
36
+ | None = None,
37
+ ) -> None:
38
+ """Creates a new Headers object.
39
+
40
+ Args:
41
+ items: Initial headers to add.
42
+ """
43
+
44
+ def __getitem__(self, key: str | HTTPHeaderName) -> str:
45
+ """Return the header value for the key.
46
+
47
+ If multiple values are present for the key, returns the first value.
48
+
49
+ Args:
50
+ key: The header name.
51
+
52
+ Raises:
53
+ KeyError: If the key is not present.
54
+ """
55
+
56
+ def __setitem__(self, key: str | HTTPHeaderName, value: str) -> None:
57
+ """Sets the header value for the key, replacing any existing values.
58
+
59
+ Args:
60
+ key: The header name.
61
+ value: The header value.
62
+ """
63
+
64
+ def __delitem__(self, key: str | HTTPHeaderName) -> None:
65
+ """Deletes all values for the key.
66
+
67
+ Args:
68
+ key: The header name.
69
+
70
+ Raises:
71
+ KeyError: If the key is not present.
72
+ """
73
+
74
+ def __iter__(self) -> Iterator[str]:
75
+ """Returns an iterator over the header names."""
76
+
77
+ def __len__(self) -> int:
78
+ """Returns the number of unique header names."""
79
+
80
+ def __eq__(self, other: object) -> bool:
81
+ """Compares the headers for equality with another Headers object,
82
+ mapping, or iterable of key-value pairs.
83
+
84
+ Args:
85
+ other: The object to compare against.
86
+ """
87
+
88
+ def get(self, key: str | HTTPHeaderName, default: str | None = None) -> str | None:
89
+ """Returns the header value for the key, or default if not present.
90
+
91
+ Args:
92
+ key: The header name.
93
+ default: The default value to return if the key is not present.
94
+ """
95
+
96
+ @overload
97
+ def pop(self, key: str | HTTPHeaderName) -> str:
98
+ """Removes and returns the header value for the key.
99
+
100
+ Args:
101
+ key: The header name.
102
+
103
+ Raises:
104
+ KeyError: If the key is not present.
105
+ """
106
+
107
+ @overload
108
+ def pop(self, key: str | HTTPHeaderName, default: _T) -> str | _T:
109
+ """Removes and returns the header value for the key, or default if not present.
110
+
111
+ Args:
112
+ key: The header name.
113
+ default: The default value to return if the key is not present.
114
+ """
115
+
116
+ def popitem(self) -> tuple[str, str]:
117
+ """Removes and returns an arbitrary (name, value) pair. Will return the same
118
+ name multiple times if it has multiple values.
119
+
120
+ Raises:
121
+ KeyError: If the headers are empty.
122
+ """
123
+
124
+ def setdefault(self, key: str | HTTPHeaderName, default: str | None = None) -> str:
125
+ """If the key is not present, sets it to the default value.
126
+ Returns the value for the key.
127
+
128
+ Args:
129
+ key: The header name.
130
+ default: The default value to set and return if the key is not present.
131
+ """
132
+
133
+ def add(self, key: str | HTTPHeaderName, value: str) -> None:
134
+ """Adds a header value for the key. Existing values are preserved.
135
+
136
+ Args:
137
+ key: The header name.
138
+ value: The header value.
139
+ """
140
+
141
+ @overload
142
+ def update(self, **kwargs: str) -> None:
143
+ """Updates headers from keyword arguments. Existing values are replaced.
144
+
145
+ Args:
146
+ **kwargs: Header names and values to set.
147
+ """
148
+ @overload
149
+ def update(
150
+ self,
151
+ items: Mapping[str | HTTPHeaderName, str]
152
+ | Iterable[tuple[str | HTTPHeaderName, str]],
153
+ /,
154
+ **kwargs: str,
155
+ ) -> None:
156
+ """Updates headers with the provided items. Existing values are replaced.
157
+
158
+ Args:
159
+ items: Header names and values to set.
160
+ **kwargs: Additional header names and values to set after items. May overwrite items.
161
+ """
162
+
163
+ def clear(self) -> None:
164
+ """Removes all headers."""
165
+
166
+ def getall(self, key: str | HTTPHeaderName) -> Sequence[str]:
167
+ """Returns all header values for the key.
168
+
169
+ Args:
170
+ key: The header name.
171
+ """
172
+
173
+ def items(self) -> ItemsView[str, str]:
174
+ """Returns a new view of all header name-value pairs, including duplicates."""
175
+
176
+ def keys(self) -> KeysView[str]:
177
+ """Returns a new view of all unique header names."""
178
+
179
+ def values(self) -> ValuesView[str]:
180
+ """Returns a new view of all header values, including duplicates."""
181
+
182
+ def __contains__(self, key: object) -> bool:
183
+ """Returns True if the header name is present.
184
+
185
+ Args:
186
+ key: The header name.
187
+ """
188
+
189
+ class HTTPVersion:
190
+ """An enumeration of HTTP versions."""
191
+
192
+ HTTP1: HTTPVersion
193
+ """HTTP/1.1"""
194
+
195
+ HTTP2: HTTPVersion
196
+ """HTTP/2"""
197
+
198
+ HTTP3: HTTPVersion
199
+ """HTTP/3"""
200
+
201
+ def __eq__(self, other: object) -> bool: ...
202
+ def __ne__(self, other: object) -> bool: ...
203
+ def __lt__(self, other: object) -> bool: ...
204
+ def __le__(self, other: object) -> bool: ...
205
+ def __gt__(self, other: object) -> bool: ...
206
+ def __ge__(self, other: object) -> bool: ...
207
+
208
+ class Client:
209
+ def __init__(self, transport: Transport | None = None) -> None:
210
+ """Creates a new asynchronous HTTP client.
211
+
212
+ The asynchronous client does not expose per-request timeouts on its methods.
213
+ Use `asyncio.wait_for` or similar to enforce timeouts on requests.
214
+
215
+ Args:
216
+ transport: The transport to use for requests. If None, the shared default
217
+ transport will be used.
218
+ """
219
+
220
+ def get(
221
+ self,
222
+ url: str,
223
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
224
+ ) -> Awaitable[FullResponse]:
225
+ """Executes a GET HTTP request.
226
+
227
+ Args:
228
+ url: The unencoded request URL.
229
+ headers: The request headers.
230
+
231
+ Raises:
232
+ ConnectionError: If the connection fails.
233
+ TimeoutError: If the request times out.
234
+ ReadError: If an error occurs reading the response.
235
+ WriteError: If an error occurs writing the request.
236
+ """
237
+
238
+ def post(
239
+ self,
240
+ url: str,
241
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
242
+ content: bytes | AsyncIterator[bytes] | None = None,
243
+ ) -> Awaitable[FullResponse]:
244
+ """Executes a POST HTTP request.
245
+
246
+ Args:
247
+ url: The unencoded request URL.
248
+ headers: The request headers.
249
+ content: The request content.
250
+
251
+ Raises:
252
+ ConnectionError: If the connection fails.
253
+ TimeoutError: If the request times out.
254
+ ReadError: If an error occurs reading the response.
255
+ WriteError: If an error occurs writing the request.
256
+ """
257
+
258
+ def delete(
259
+ self,
260
+ url: str,
261
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
262
+ ) -> Awaitable[FullResponse]:
263
+ """Executes a DELETE HTTP request.
264
+
265
+ Args:
266
+ url: The unencoded request URL.
267
+ headers: The request headers.
268
+
269
+ Raises:
270
+ ConnectionError: If the connection fails.
271
+ TimeoutError: If the request times out.
272
+ ReadError: If an error occurs reading the response.
273
+ WriteError: If an error occurs writing the request.
274
+ """
275
+
276
+ def head(
277
+ self,
278
+ url: str,
279
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
280
+ ) -> Awaitable[FullResponse]:
281
+ """Executes a HEAD HTTP request.
282
+
283
+ Args:
284
+ url: The unencoded request URL.
285
+ headers: The request headers.
286
+
287
+ Raises:
288
+ ConnectionError: If the connection fails.
289
+ TimeoutError: If the request times out.
290
+ ReadError: If an error occurs reading the response.
291
+ WriteError: If an error occurs writing the request.
292
+ """
293
+
294
+ def options(
295
+ self,
296
+ url: str,
297
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
298
+ ) -> Awaitable[FullResponse]:
299
+ """Executes a OPTIONS HTTP request.
300
+
301
+ Args:
302
+ url: The unencoded request URL.
303
+ headers: The request headers.
304
+
305
+ Raises:
306
+ ConnectionError: If the connection fails.
307
+ TimeoutError: If the request times out.
308
+ ReadError: If an error occurs reading the response.
309
+ WriteError: If an error occurs writing the request.
310
+ """
311
+
312
+ def patch(
313
+ self,
314
+ url: str,
315
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
316
+ content: bytes | AsyncIterator[bytes] | None = None,
317
+ ) -> Awaitable[FullResponse]:
318
+ """Executes a PATCH HTTP request.
319
+
320
+ Args:
321
+ url: The unencoded request URL.
322
+ headers: The request headers.
323
+ content: The request content.
324
+ timeout: The timeout for the request in seconds.
325
+
326
+ Raises:
327
+ ConnectionError: If the connection fails.
328
+ TimeoutError: If the request times out.
329
+ ReadError: If an error occurs reading the response.
330
+ WriteError: If an error occurs writing the request.
331
+ """
332
+
333
+ def put(
334
+ self,
335
+ url: str,
336
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
337
+ content: bytes | AsyncIterator[bytes] | None = None,
338
+ ) -> Awaitable[FullResponse]:
339
+ """Executes a PUT HTTP request.
340
+
341
+ Args:
342
+ url: The unencoded request URL.
343
+ headers: The request headers.
344
+ content: The request content.
345
+
346
+ Raises:
347
+ ConnectionError: If the connection fails.
348
+ TimeoutError: If the request times out.
349
+ ReadError: If an error occurs reading the response.
350
+ WriteError: If an error occurs writing the request.
351
+ """
352
+
353
+ def execute(
354
+ self,
355
+ method: str,
356
+ url: str,
357
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
358
+ content: bytes | AsyncIterator[bytes] | None = None,
359
+ ) -> Awaitable[FullResponse]:
360
+ """Executes an HTTP request, returning the full buffered response.
361
+
362
+ Args:
363
+ method: The HTTP method.
364
+ url: The unencoded request URL.
365
+ headers: The request headers.
366
+ content: The request content.
367
+
368
+ Raises:
369
+ ConnectionError: If the connection fails.
370
+ TimeoutError: If the request times out.
371
+ ReadError: If an error occurs reading the response.
372
+ WriteError: If an error occurs writing the request.
373
+ """
374
+
375
+ def stream(
376
+ self,
377
+ method: str,
378
+ url: str,
379
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
380
+ content: bytes | AsyncIterator[bytes] | None = None,
381
+ ) -> Awaitable[Response]:
382
+ """Executes an HTTP request, allowing the response content to be streamed.
383
+
384
+ Args:
385
+ method: The HTTP method.
386
+ url: The unencoded request URL.
387
+ headers: The request headers.
388
+ content: The request content.
389
+
390
+ Raises:
391
+ ConnectionError: If the connection fails.
392
+ TimeoutError: If the request times out.
393
+ ReadError: If an error occurs reading the response.
394
+ WriteError: If an error occurs writing the request.
395
+ """
396
+
397
+ @runtime_checkable
398
+ class Transport(Protocol):
399
+ """Protocol for asynchronous HTTP transport implementations.
400
+
401
+ The default implementation of Transport is HTTPTransport which issues requests.
402
+ Custom implementations may be useful to:
403
+
404
+ - Mock requests for testing.
405
+ - Add middleware wrapping transports
406
+ """
407
+
408
+ def execute(self, request: Request) -> Awaitable[Response]:
409
+ """Executes a request."""
410
+
411
+ class HTTPTransport:
412
+ """An HTTP transport implementation using reqwest."""
413
+
414
+ def __init__(
415
+ self,
416
+ *,
417
+ tls_ca_cert: bytes | None = None,
418
+ tls_key: bytes | None = None,
419
+ tls_cert: bytes | None = None,
420
+ http_version: HTTPVersion | None = None,
421
+ timeout: float | None = None,
422
+ connect_timeout: float | None = None,
423
+ read_timeout: float | None = None,
424
+ pool_idle_timeout: float | None = None,
425
+ pool_max_idle_per_host: int | None = None,
426
+ tcp_keepalive_interval: float | None = None,
427
+ enable_gzip: bool = False,
428
+ enable_brotli: bool = False,
429
+ enable_zstd: bool = False,
430
+ use_system_dns: bool = False,
431
+ ) -> None:
432
+ """Creates a new HTTPTransport object.
433
+
434
+ Without any arguments, the transport behaves like a raw, low-level HTTP transport,
435
+ with no timeouts or other higher level behavior. When creating a transport, take care
436
+ to set options to meet your needs. Also consider using get_default_transport instead
437
+ which is preconfigured with reasonable defaults, though does not support custom TLS
438
+ certificates.
439
+
440
+ Args:
441
+ tls_ca_cert: The CA certificate to use to verify the server for TLS connections.
442
+ tls_key: The client private key to identify the client for mTLS connections.
443
+ tls_cert must also be set.
444
+ tls_cert: The client certificate to identify the client for mTLS connections.
445
+ tls_key must also be set.
446
+ http_version: The HTTP version to use for requests. If unset, HTTP/1 is used for
447
+ plaintext and ALPN negotiates the version for TLS connections
448
+ which typically means HTTP/2 if the server supports it.
449
+ timeout: Default timeout for requests in seconds. This is the timeout from
450
+ the start of the request to the end of the response.
451
+ connect_timeout: Timeout for connection establishment in seconds.
452
+ read_timeout: Timeout for each read operation of a request in seconds.
453
+ pool_idle_timeout: Timeout for idle connections in the connection pool in seconds.
454
+ pool_max_idle_per_host: Maximum number of idle connections to keep in the pool per host.
455
+ Defaults to 2.
456
+ tcp_keepalive_interval: Interval for TCP keepalive probes in seconds.
457
+ enable_gzip: Whether to enable gzip decompression for responses.
458
+ enable_brotli: Whether to enable brotli decompression for responses.
459
+ enable_zstd: Whether to enable zstd decompression for responses.
460
+ use_system_dns: Whether to use the system DNS resolver. By default, pyqwest uses an
461
+ asynchronous DNS resolver implemented in Rust, but it can have different
462
+ behavior from system DNS in certain environments. Try enabling this option if
463
+ you have any DNS resolution issues.
464
+ """
465
+
466
+ def __aenter__(self) -> Awaitable[HTTPTransport]:
467
+ """Enters the context manager for the transport to automatically close it when
468
+ leaving.
469
+ """
470
+
471
+ def __aexit__(
472
+ self,
473
+ _exc_type: type[BaseException] | None,
474
+ _exc_value: BaseException | None,
475
+ _traceback: TracebackType | None,
476
+ ) -> Awaitable[None]:
477
+ """Exits the context manager for the transport, closing it."""
478
+
479
+ def execute(self, request: Request) -> Awaitable[Response]:
480
+ """Executes the given request, returning the response.
481
+
482
+ Args:
483
+ request: The request to execute.
484
+
485
+ Raises:
486
+ ConnectionError: If the connection fails.
487
+ TimeoutError: If the request times out.
488
+ ReadError: If an error occurs reading the response.
489
+ WriteError: If an error occurs writing the request.
490
+ """
491
+
492
+ def aclose(self) -> Awaitable[None]:
493
+ """Closes the transport, releasing any underlying resources."""
494
+
495
+ def get_default_transport() -> HTTPTransport:
496
+ """Returns the singleton default HTTP transport instance used by clients that do not
497
+ specify a transport.
498
+
499
+ The default transport is constructed as follows:
500
+ ```
501
+ HTTPTransport(
502
+ connect_timeout=30.0,
503
+ pool_idle_timeout=90.0,
504
+ pool_max_idle_per_host=2,
505
+ tcp_keepalive_interval=30.0,
506
+ enable_gzip: bool = True,
507
+ enable_brotli: bool = True,
508
+ enable_zstd: bool = True,
509
+ )
510
+ ```
511
+ """
512
+
513
+ class Request:
514
+ """An HTTP request."""
515
+
516
+ def __init__(
517
+ self,
518
+ method: str,
519
+ url: str,
520
+ headers: Headers | None = None,
521
+ content: bytes | AsyncIterator[bytes] | None = None,
522
+ ) -> None:
523
+ """Creates a new Request object.
524
+
525
+ Args:
526
+ method: The HTTP method.
527
+ url: The unencoded request URL.
528
+ headers: The request headers.
529
+ content: The request content.
530
+ """
531
+
532
+ @property
533
+ def method(self) -> str:
534
+ """Returns the HTTP method of the request."""
535
+
536
+ @property
537
+ def url(self) -> str:
538
+ """Returns the unencoded request URL."""
539
+
540
+ @property
541
+ def headers(self) -> Headers:
542
+ """Returns the request headers."""
543
+
544
+ @property
545
+ def content(self) -> AsyncIterator[bytes]:
546
+ """Returns an async iterator over the request content."""
547
+
548
+ class Response:
549
+ """An HTTP response."""
550
+
551
+ def __init__(
552
+ self,
553
+ *,
554
+ status: int,
555
+ http_version: HTTPVersion | None = None,
556
+ headers: Headers | None = None,
557
+ content: bytes | AsyncIterator[Buffer] | None = None,
558
+ trailers: Headers | None = None,
559
+ ) -> None:
560
+ """Creates a new Response object.
561
+
562
+ Care must be taken if your service uses trailers and you override content.
563
+ Trailers will not be received without fully consuming the original response content.
564
+ Patterns that wrap the original response content should not have any issue but if
565
+ you replace it completely and need trailers, make sure to still read and discard
566
+ the original content.
567
+
568
+ Args:
569
+ status: The HTTP status code of the response.
570
+ http_version: The HTTP version of the response.
571
+ headers: The response headers.
572
+ content: The response content.
573
+ trailers: The response trailers.
574
+ """
575
+
576
+ def __aenter__(self) -> Awaitable[Response]:
577
+ """Enters the context manager for the response to automatically close it when
578
+ leaving.
579
+
580
+ Note that if your code is guaranteed to fully consume the response content,
581
+ it is not necessary to explicitly close the response.
582
+ """
583
+
584
+ def __aexit__(
585
+ self,
586
+ _exc_type: type[BaseException] | None,
587
+ _exc_value: BaseException | None,
588
+ _traceback: TracebackType | None,
589
+ ) -> Awaitable[None]:
590
+ """Exits the context manager for the response, closing it."""
591
+
592
+ @property
593
+ def status(self) -> int:
594
+ """Returns the HTTP status code of the response."""
595
+
596
+ @property
597
+ def http_version(self) -> HTTPVersion:
598
+ """Returns the HTTP version of the response."""
599
+
600
+ @property
601
+ def headers(self) -> Headers:
602
+ """Returns the response headers."""
603
+
604
+ @property
605
+ def content(self) -> AsyncIterator[Buffer]:
606
+ """Returns an asynchronous iterator over the response content."""
607
+
608
+ @property
609
+ def trailers(self) -> Headers:
610
+ """Returns the response trailers.
611
+
612
+ Because trailers complete the response, this will only be filled after fully
613
+ consuming the content iterator.
614
+ """
615
+
616
+ def aclose(self) -> Awaitable[None]:
617
+ """Closes the response, releasing any underlying resources.
618
+
619
+ Note that if your code is guaranteed to fully consume the response content,
620
+ it is not necessary to explicitly close the response.
621
+ """
622
+
623
+ class SyncClient:
624
+ """A synchronous HTTP client.
625
+
626
+ A client is a lightweight wrapper around a SyncTransport, providing convenience methods
627
+ for common HTTP operations with buffering.
628
+ """
629
+
630
+ def __init__(self, transport: SyncTransport | None = None) -> None:
631
+ """Creates a new synchronous HTTP client.
632
+
633
+ Args:
634
+ transport: The transport to use for requests. If None, the shared default
635
+ transport will be used.
636
+ """
637
+
638
+ def get(
639
+ self,
640
+ url: str,
641
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
642
+ timeout: float | None = None,
643
+ ) -> FullResponse:
644
+ """Executes a GET HTTP request.
645
+
646
+ Args:
647
+ url: The unencoded request URL.
648
+ headers: The request headers.
649
+ timeout: The timeout for the request in seconds.
650
+
651
+ Raises:
652
+ ConnectionError: If the connection fails.
653
+ TimeoutError: If the request times out.
654
+ ReadError: If an error occurs reading the response.
655
+ WriteError: If an error occurs writing the request.
656
+ """
657
+
658
+ def post(
659
+ self,
660
+ url: str,
661
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
662
+ content: bytes | Iterable[bytes] | None = None,
663
+ timeout: float | None = None,
664
+ ) -> FullResponse:
665
+ """Executes a POST HTTP request.
666
+
667
+ Args:
668
+ url: The unencoded request URL.
669
+ headers: The request headers.
670
+ content: The request content.
671
+ timeout: The timeout for the request in seconds.
672
+
673
+ Raises:
674
+ ConnectionError: If the connection fails.
675
+ TimeoutError: If the request times out.
676
+ ReadError: If an error occurs reading the response.
677
+ WriteError: If an error occurs writing the request.
678
+ """
679
+
680
+ def delete(
681
+ self,
682
+ url: str,
683
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
684
+ timeout: float | None = None,
685
+ ) -> FullResponse:
686
+ """Executes a DELETE HTTP request.
687
+
688
+ Args:
689
+ url: The unencoded request URL.
690
+ headers: The request headers.
691
+ timeout: The timeout for the request in seconds.
692
+
693
+ Raises:
694
+ ConnectionError: If the connection fails.
695
+ TimeoutError: If the request times out.
696
+ ReadError: If an error occurs reading the response.
697
+ WriteError: If an error occurs writing the request.
698
+ """
699
+
700
+ def head(
701
+ self,
702
+ url: str,
703
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
704
+ timeout: float | None = None,
705
+ ) -> FullResponse:
706
+ """Executes a HEAD HTTP request.
707
+
708
+ Args:
709
+ url: The unencoded request URL.
710
+ headers: The request headers.
711
+ timeout: The timeout for the request in seconds.
712
+
713
+ Raises:
714
+ ConnectionError: If the connection fails.
715
+ TimeoutError: If the request times out.
716
+ ReadError: If an error occurs reading the response.
717
+ WriteError: If an error occurs writing the request.
718
+ """
719
+
720
+ def options(
721
+ self,
722
+ url: str,
723
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
724
+ timeout: float | None = None,
725
+ ) -> FullResponse:
726
+ """Executes a OPTIONS HTTP request.
727
+
728
+ Args:
729
+ url: The unencoded request URL.
730
+ headers: The request headers.
731
+ timeout: The timeout for the request in seconds.
732
+
733
+ Raises:
734
+ ConnectionError: If the connection fails.
735
+ TimeoutError: If the request times out.
736
+ ReadError: If an error occurs reading the response.
737
+ WriteError: If an error occurs writing the request.
738
+ """
739
+
740
+ def patch(
741
+ self,
742
+ url: str,
743
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
744
+ content: bytes | Iterable[bytes] | None = None,
745
+ timeout: float | None = None,
746
+ ) -> FullResponse:
747
+ """Executes a PATCH HTTP request.
748
+
749
+ Args:
750
+ url: The unencoded request URL.
751
+ headers: The request headers.
752
+ content: The request content.
753
+ timeout: The timeout for the request in seconds.
754
+
755
+ Raises:
756
+ ConnectionError: If the connection fails.
757
+ TimeoutError: If the request times out.
758
+ ReadError: If an error occurs reading the response.
759
+ WriteError: If an error occurs writing the request.
760
+ """
761
+
762
+ def put(
763
+ self,
764
+ url: str,
765
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
766
+ content: bytes | Iterable[bytes] | None = None,
767
+ timeout: float | None = None,
768
+ ) -> FullResponse:
769
+ """Executes a PUT HTTP request.
770
+
771
+ Args:
772
+ url: The unencoded request URL.
773
+ headers: The request headers.
774
+ content: The request content.
775
+ timeout: The timeout for the request in seconds.
776
+
777
+ Raises:
778
+ ConnectionError: If the connection fails.
779
+ TimeoutError: If the request times out.
780
+ ReadError: If an error occurs reading the response.
781
+ WriteError: If an error occurs writing the request.
782
+ """
783
+
784
+ def execute(
785
+ self,
786
+ method: str,
787
+ url: str,
788
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
789
+ content: bytes | Iterable[bytes] | None = None,
790
+ timeout: float | None = None,
791
+ ) -> FullResponse:
792
+ """Executes an HTTP request, returning the full buffered response.
793
+
794
+ Args:
795
+ method: The HTTP method.
796
+ url: The unencoded request URL.
797
+ headers: The request headers.
798
+ content: The request content.
799
+ timeout: The timeout for the request in seconds.
800
+
801
+ Raises:
802
+ ConnectionError: If the connection fails.
803
+ TimeoutError: If the request times out.
804
+ ReadError: If an error occurs reading the response.
805
+ WriteError: If an error occurs writing the request.
806
+ """
807
+
808
+ def stream(
809
+ self,
810
+ method: str,
811
+ url: str,
812
+ headers: Headers | Mapping[str, str] | Iterable[tuple[str, str]] | None = None,
813
+ content: bytes | Iterable[bytes] | None = None,
814
+ timeout: float | None = None,
815
+ ) -> AbstractContextManager[SyncResponse]:
816
+ """Executes an HTTP request, allowing the response content to be streamed.
817
+
818
+ Args:
819
+ method: The HTTP method.
820
+ url: The unencoded request URL.
821
+ headers: The request headers.
822
+ content: The request content.
823
+ timeout: The timeout for the request in seconds.
824
+
825
+ Raises:
826
+ ConnectionError: If the connection fails.
827
+ TimeoutError: If the request times out.
828
+ ReadError: If an error occurs reading the response.
829
+ WriteError: If an error occurs writing the request.
830
+ """
831
+
832
+ @runtime_checkable
833
+ class SyncTransport(Protocol):
834
+ """Protocol for synchronous HTTP transport implementations.
835
+
836
+ The default implementation of SyncTransport is SyncHTTPTransport which issues requests.
837
+ Custom implementations may be useful to:
838
+
839
+ - Mock requests for testing.
840
+ - Add middleware wrapping transports
841
+ """
842
+
843
+ def execute_sync(self, request: SyncRequest) -> SyncResponse:
844
+ """Executes a request."""
845
+
846
+ class SyncHTTPTransport:
847
+ """An HTTP transport implementation using reqwest."""
848
+
849
+ def __init__(
850
+ self,
851
+ *,
852
+ tls_ca_cert: bytes | None = None,
853
+ tls_key: bytes | None = None,
854
+ tls_cert: bytes | None = None,
855
+ http_version: HTTPVersion | None = None,
856
+ timeout: float | None = None,
857
+ connect_timeout: float | None = None,
858
+ read_timeout: float | None = None,
859
+ pool_idle_timeout: float | None = None,
860
+ pool_max_idle_per_host: int | None = None,
861
+ tcp_keepalive_interval: float | None = None,
862
+ enable_gzip: bool = False,
863
+ enable_brotli: bool = False,
864
+ enable_zstd: bool = False,
865
+ use_system_dns: bool = False,
866
+ ) -> None:
867
+ """Creates a new SyncHTTPTransport object.
868
+
869
+ Without any arguments, the transport behaves like a raw, low-level HTTP transport,
870
+ with no timeouts or other higher level behavior. When creating a transport, take care
871
+ to set options to meet your needs. Also consider using get_default_transport instead
872
+ which is preconfigured with reasonable defaults, though does not support custom TLS
873
+ certificates.
874
+
875
+ Args:
876
+ tls_ca_cert: The CA certificate to use to verify the server for TLS connections.
877
+ tls_key: The client private key to identify the client for mTLS connections.
878
+ tls_cert must also be set.
879
+ tls_cert: The client certificate to identify the client for mTLS connections.
880
+ tls_key must also be set.
881
+ http_version: The HTTP version to use for requests. If unset, HTTP/1 is used for
882
+ plaintext and ALPN negotiates the version for TLS connections
883
+ which typically means HTTP/2 if the server supports it.
884
+ timeout: Default timeout for requests in seconds. This is the timeout from
885
+ the start of the request to the end of the response.
886
+ connect_timeout: Timeout for connection establishment in seconds.
887
+ read_timeout: Timeout for each read operation of a request in seconds.
888
+ pool_idle_timeout: Timeout for idle connections in the connection pool in seconds.
889
+ pool_max_idle_per_host: Maximum number of idle connections to keep in the pool per host.
890
+ Defaults to 2.
891
+ tcp_keepalive_interval: Interval for TCP keepalive probes in seconds.
892
+ enable_gzip: Whether to enable gzip decompression for responses.
893
+ enable_brotli: Whether to enable brotli decompression for responses.
894
+ enable_zstd: Whether to enable zstd decompression for responses.
895
+ use_system_dns: Whether to use the system DNS resolver. By default, pyqwest uses an
896
+ asynchronous DNS resolver implemented in Rust, but it can have different
897
+ behavior from system DNS in certain environments. Try enabling this option if
898
+ you have any DNS resolution issues.
899
+ """
900
+
901
+ def __enter__(self) -> SyncHTTPTransport:
902
+ """Enters the context manager for the transport to automatically
903
+ close it when leaving.
904
+ """
905
+
906
+ def __exit__(
907
+ self,
908
+ _exc_type: type[BaseException] | None,
909
+ _exc_value: BaseException | None,
910
+ _traceback: TracebackType | None,
911
+ ) -> None:
912
+ """Exits the context manager for the transport, closing it."""
913
+
914
+ def execute_sync(self, request: SyncRequest) -> SyncResponse:
915
+ """Executes the given request, returning the response.
916
+
917
+ Args:
918
+ request: The request to execute.
919
+ """
920
+
921
+ def close(self) -> None:
922
+ """Closes the transport, releasing any underlying resources."""
923
+
924
+ def get_default_sync_transport() -> SyncHTTPTransport:
925
+ """Returns the singleton default HTTP transport instance used by synchronous clients that do not
926
+ specify a transport.ult HTTP transport instance used by clients that do not
927
+ specify a transport.
928
+
929
+ The default transport is constructed as follows:
930
+ ```
931
+ SyncHTTPTransport(
932
+ connect_timeout=30.0,
933
+ pool_idle_timeout=90.0,
934
+ pool_max_idle_per_host=2,
935
+ tcp_keepalive_interval=30.0,
936
+ enable_gzip: bool = True,
937
+ enable_brotli: bool = True,
938
+ enable_zstd: bool = True,
939
+ )
940
+ ```
941
+ """
942
+
943
+ class SyncRequest:
944
+ """An HTTP request."""
945
+
946
+ def __init__(
947
+ self,
948
+ method: str,
949
+ url: str,
950
+ headers: Headers | None = None,
951
+ content: bytes | Iterable[bytes] | None = None,
952
+ ) -> None:
953
+ """Creates a new SyncRequest object.
954
+
955
+ Args:
956
+ method: The HTTP method.
957
+ url: The unencoded request URL.
958
+ headers: The request headers.
959
+ content: The request content.
960
+ timeout: The timeout for the request in seconds.
961
+ """
962
+
963
+ @property
964
+ def method(self) -> str:
965
+ """Returns the HTTP method of the request."""
966
+
967
+ @property
968
+ def url(self) -> str:
969
+ """Returns the unencoded request URL."""
970
+
971
+ @property
972
+ def headers(self) -> Headers:
973
+ """Returns the request headers."""
974
+
975
+ @property
976
+ def content(self) -> Iterator[bytes]:
977
+ """Returns an iterator over the request content."""
978
+
979
+ class SyncResponse:
980
+ """An HTTP response."""
981
+
982
+ def __init__(
983
+ self,
984
+ *,
985
+ status: int,
986
+ http_version: HTTPVersion | None = None,
987
+ headers: Headers | None = None,
988
+ content: bytes | Iterable[Buffer] | None = None,
989
+ trailers: Headers | None = None,
990
+ ) -> None:
991
+ """Creates a new SyncResponse object.
992
+
993
+ Care must be taken if your service uses trailers and you override content.
994
+ Trailers will not be received without fully consuming the original response content.
995
+ Patterns that wrap the original response content should not have any issue but if
996
+ you replace it completely and need trailers, make sure to still read and discard
997
+ the original content.
998
+
999
+ Args:
1000
+ status: The HTTP status code of the response.
1001
+ http_version: The HTTP version of the response.
1002
+ headers: The response headers.
1003
+ content: The response content.
1004
+ trailers: The response trailers.
1005
+ """
1006
+
1007
+ def __enter__(self) -> SyncResponse:
1008
+ """Enters the context manager for the response to automatically
1009
+ close it when leaving.
1010
+
1011
+ Note that if your code is guaranteed to fully consume the response content,
1012
+ it is not necessary to explicitly close the response.
1013
+ """
1014
+
1015
+ def __exit__(
1016
+ self,
1017
+ _exc_type: type[BaseException] | None,
1018
+ _exc_value: BaseException | None,
1019
+ _traceback: TracebackType | None,
1020
+ ) -> None:
1021
+ """Exits the context manager for the response, closing it."""
1022
+
1023
+ @property
1024
+ def status(self) -> int:
1025
+ """Returns the HTTP status code of the response."""
1026
+
1027
+ @property
1028
+ def http_version(self) -> HTTPVersion:
1029
+ """Returns the HTTP version of the response."""
1030
+
1031
+ @property
1032
+ def headers(self) -> Headers:
1033
+ """Returns the response headers."""
1034
+
1035
+ @property
1036
+ def content(self) -> Iterator[Buffer]:
1037
+ """Returns an iterator over the response content."""
1038
+
1039
+ @property
1040
+ def trailers(self) -> Headers:
1041
+ """Returns the response trailers.
1042
+
1043
+ Because trailers complete the response, this will only be filled after fully
1044
+ consuming the content iterator.
1045
+ """
1046
+
1047
+ def close(self) -> None:
1048
+ """Closes the response, releasing any underlying resources.
1049
+
1050
+ Note that if your code is guaranteed to fully consume the response content,
1051
+ it is not necessary to explicitly close the response.
1052
+ """
1053
+
1054
+ class FullResponse:
1055
+ """A fully buffered HTTP response."""
1056
+
1057
+ def __init__(
1058
+ self, status: int, headers: Headers, content: bytes, trailers: Headers
1059
+ ) -> None:
1060
+ """Creates a new FullResponse object.
1061
+
1062
+ Args:
1063
+ status: The HTTP status code of the response.
1064
+ headers: The response headers.
1065
+ content: The response content.
1066
+ trailers: The response trailers.
1067
+ """
1068
+
1069
+ @property
1070
+ def status(self) -> int:
1071
+ """Returns the HTTP status code of the response."""
1072
+
1073
+ @property
1074
+ def headers(self) -> Headers:
1075
+ """Returns the response headers."""
1076
+
1077
+ @property
1078
+ def content(self) -> bytes:
1079
+ """Returns the response content."""
1080
+
1081
+ @property
1082
+ def trailers(self) -> Headers:
1083
+ """Returns the response trailers."""
1084
+
1085
+ def text(self) -> str:
1086
+ """Returns the response content decoded as text.
1087
+
1088
+ The encoding for decoding is determined from the content-type header if present,
1089
+ defaulting to UTF-8 otherwise.
1090
+ """
1091
+
1092
+ def json(self) -> JSON:
1093
+ """Parses and returns the response content as JSON.
1094
+
1095
+ The content-type header is not checked when using this method.
1096
+ """
1097
+
1098
+ class StreamErrorCode:
1099
+ NO_ERROR: StreamErrorCode
1100
+ PROTOCOL_ERROR: StreamErrorCode
1101
+ INTERNAL_ERROR: StreamErrorCode
1102
+ FLOW_CONTROL_ERROR: StreamErrorCode
1103
+ SETTINGS_TIMEOUT: StreamErrorCode
1104
+ STREAM_CLOSED: StreamErrorCode
1105
+ FRAME_SIZE_ERROR: StreamErrorCode
1106
+ REFUSED_STREAM: StreamErrorCode
1107
+ CANCEL: StreamErrorCode
1108
+ COMPRESSION_ERROR: StreamErrorCode
1109
+ CONNECT_ERROR: StreamErrorCode
1110
+ ENHANCE_YOUR_CALM: StreamErrorCode
1111
+ INADEQUATE_SECURITY: StreamErrorCode
1112
+ HTTP_1_1_REQUIRED: StreamErrorCode
1113
+
1114
+ class StreamError(Exception):
1115
+ """An error representing an HTTP/2+ stream error."""
1116
+
1117
+ def __init__(self, message: str, code: StreamErrorCode) -> None:
1118
+ """Creates a new StreamError.
1119
+
1120
+ Args:
1121
+ message: The error message.
1122
+ code: The stream error code.
1123
+ """
1124
+
1125
+ @property
1126
+ def code(self) -> StreamErrorCode:
1127
+ """The stream error code."""
1128
+
1129
+ class ReadError(Exception):
1130
+ """An error representing a read error during response reading."""
1131
+
1132
+ class WriteError(Exception):
1133
+ """An error representing a write error during request sending."""
1134
+
1135
+ class HTTPHeaderName:
1136
+ """An enum type corresponding to HTTP header names."""
1137
+
1138
+ def __init__(self, name: str) -> None:
1139
+ """Creates a new HTTPHeaderName. When available, prefer one of the
1140
+ class attributes.
1141
+
1142
+ Args:
1143
+ name: The header name.
1144
+ """
1145
+
1146
+ ACCEPT: HTTPHeaderName
1147
+ """The "accept" header."""
1148
+
1149
+ ACCEPT_CHARSET: HTTPHeaderName
1150
+ """The "accept-charset" header."""
1151
+
1152
+ ACCEPT_ENCODING: HTTPHeaderName
1153
+ """The "accept-encoding" header."""
1154
+
1155
+ ACCEPT_LANGUAGE: HTTPHeaderName
1156
+ """The "accept-language" header."""
1157
+
1158
+ ACCEPT_RANGES: HTTPHeaderName
1159
+ """The "accept-ranges" header."""
1160
+
1161
+ ACCESS_CONTROL_ALLOW_CREDENTIALS: HTTPHeaderName
1162
+ """The "access-control-allow-credentials" header."""
1163
+
1164
+ ACCESS_CONTROL_ALLOW_HEADERS: HTTPHeaderName
1165
+ """The "access-control-allow-headers" header."""
1166
+
1167
+ ACCESS_CONTROL_ALLOW_METHODS: HTTPHeaderName
1168
+ """The "access-control-allow-methods" header."""
1169
+
1170
+ ACCESS_CONTROL_ALLOW_ORIGIN: HTTPHeaderName
1171
+ """The "access-control-allow-origin" header."""
1172
+
1173
+ ACCESS_CONTROL_EXPOSE_HEADERS: HTTPHeaderName
1174
+ """The "access-control-expose-headers" header."""
1175
+
1176
+ ACCESS_CONTROL_MAX_AGE: HTTPHeaderName
1177
+ """The "access-control-max-age" header."""
1178
+
1179
+ ACCESS_CONTROL_REQUEST_HEADERS: HTTPHeaderName
1180
+ """The "access-control-request-headers" header."""
1181
+
1182
+ ACCESS_CONTROL_REQUEST_METHOD: HTTPHeaderName
1183
+ """The "access-control-request-method" header."""
1184
+
1185
+ AGE: HTTPHeaderName
1186
+ """The "age" header."""
1187
+
1188
+ ALLOW: HTTPHeaderName
1189
+ """The "allow" header."""
1190
+
1191
+ ALT_SVC: HTTPHeaderName
1192
+ """The "alt-svc" header."""
1193
+
1194
+ AUTHORIZATION: HTTPHeaderName
1195
+ """The "authorization" header."""
1196
+
1197
+ CACHE_CONTROL: HTTPHeaderName
1198
+ """The "cache-control" header."""
1199
+
1200
+ CACHE_STATUS: HTTPHeaderName
1201
+ """The "cache-status" header."""
1202
+
1203
+ CDN_CACHE_CONTROL: HTTPHeaderName
1204
+ """The "cdn-cache-control" header."""
1205
+
1206
+ CONNECTION: HTTPHeaderName
1207
+ """The "connection" header."""
1208
+
1209
+ CONTENT_DISPOSITION: HTTPHeaderName
1210
+ """The "content-disposition" header."""
1211
+
1212
+ CONTENT_ENCODING: HTTPHeaderName
1213
+ """The "content-encoding" header."""
1214
+
1215
+ CONTENT_LANGUAGE: HTTPHeaderName
1216
+ """The "content-language" header."""
1217
+
1218
+ CONTENT_LENGTH: HTTPHeaderName
1219
+ """The "content-length" header."""
1220
+
1221
+ CONTENT_LOCATION: HTTPHeaderName
1222
+ """The "content-location" header."""
1223
+
1224
+ CONTENT_RANGE: HTTPHeaderName
1225
+ """The "content-range" header."""
1226
+
1227
+ CONTENT_SECURITY_POLICY: HTTPHeaderName
1228
+ """The "content-security-policy" header."""
1229
+
1230
+ CONTENT_SECURITY_POLICY_REPORT_ONLY: HTTPHeaderName
1231
+ """The "content-security-policy-report-only" header."""
1232
+
1233
+ CONTENT_TYPE: HTTPHeaderName
1234
+ """The "content-type" header."""
1235
+
1236
+ COOKIE: HTTPHeaderName
1237
+ """The "cookie" header."""
1238
+
1239
+ DNT: HTTPHeaderName
1240
+ """The "dnt" header."""
1241
+
1242
+ DATE: HTTPHeaderName
1243
+ """The "date" header."""
1244
+
1245
+ ETAG: HTTPHeaderName
1246
+ """The "etag" header."""
1247
+
1248
+ EXPECT: HTTPHeaderName
1249
+ """The "expect" header."""
1250
+
1251
+ EXPIRES: HTTPHeaderName
1252
+ """The "expires" header."""
1253
+
1254
+ FORWARDED: HTTPHeaderName
1255
+ """The "forwarded" header."""
1256
+
1257
+ FROM: HTTPHeaderName
1258
+ """The "from" header."""
1259
+
1260
+ HOST: HTTPHeaderName
1261
+ """The "host" header."""
1262
+
1263
+ IF_MATCH: HTTPHeaderName
1264
+ """The "if-match" header."""
1265
+
1266
+ IF_MODIFIED_SINCE: HTTPHeaderName
1267
+ """The "if-modified-since" header."""
1268
+
1269
+ IF_NONE_MATCH: HTTPHeaderName
1270
+ """The "if-none-match" header."""
1271
+
1272
+ IF_RANGE: HTTPHeaderName
1273
+ """The "if-range" header."""
1274
+
1275
+ IF_UNMODIFIED_SINCE: HTTPHeaderName
1276
+ """The "if-unmodified-since" header."""
1277
+
1278
+ LAST_MODIFIED: HTTPHeaderName
1279
+ """The "last-modified" header."""
1280
+
1281
+ LINK: HTTPHeaderName
1282
+ """The "link" header."""
1283
+
1284
+ LOCATION: HTTPHeaderName
1285
+ """The "location" header."""
1286
+
1287
+ MAX_FORWARDS: HTTPHeaderName
1288
+ """The "max-forwards" header."""
1289
+
1290
+ ORIGIN: HTTPHeaderName
1291
+ """The "origin" header."""
1292
+
1293
+ PRAGMA: HTTPHeaderName
1294
+ """The "pragma" header."""
1295
+
1296
+ PROXY_AUTHENTICATE: HTTPHeaderName
1297
+ """The "proxy-authenticate" header."""
1298
+
1299
+ PROXY_AUTHORIZATION: HTTPHeaderName
1300
+ """The "proxy-authorization" header."""
1301
+
1302
+ PUBLIC_KEY_PINS: HTTPHeaderName
1303
+ """The "public-key-pins" header."""
1304
+
1305
+ PUBLIC_KEY_PINS_REPORT_ONLY: HTTPHeaderName
1306
+ """The "public-key-pins-report-only" header."""
1307
+
1308
+ RANGE: HTTPHeaderName
1309
+ """The "range" header."""
1310
+
1311
+ REFERER: HTTPHeaderName
1312
+ """The "referer" header."""
1313
+
1314
+ REFERRER_POLICY: HTTPHeaderName
1315
+ """The "referrer-policy" header."""
1316
+
1317
+ REFRESH: HTTPHeaderName
1318
+ """The "refresh" header."""
1319
+
1320
+ RETRY_AFTER: HTTPHeaderName
1321
+ """The "retry-after" header."""
1322
+
1323
+ SEC_WEBSOCKET_ACCEPT: HTTPHeaderName
1324
+ """The "sec-websocket-accept" header."""
1325
+
1326
+ SEC_WEBSOCKET_EXTENSIONS: HTTPHeaderName
1327
+ """The "sec-websocket-extensions" header."""
1328
+
1329
+ SEC_WEBSOCKET_KEY: HTTPHeaderName
1330
+ """The "sec-websocket-key" header."""
1331
+
1332
+ SEC_WEBSOCKET_PROTOCOL: HTTPHeaderName
1333
+ """The "sec-websocket-protocol" header."""
1334
+
1335
+ SEC_WEBSOCKET_VERSION: HTTPHeaderName
1336
+ """The "sec-websocket-version" header."""
1337
+
1338
+ SERVER: HTTPHeaderName
1339
+ """The "server" header."""
1340
+
1341
+ SET_COOKIE: HTTPHeaderName
1342
+ """The "set-cookie" header."""
1343
+
1344
+ STRICT_TRANSPORT_SECURITY: HTTPHeaderName
1345
+ """The "strict-transport-security" header."""
1346
+
1347
+ TE: HTTPHeaderName
1348
+ """The "te" header."""
1349
+
1350
+ TRAILER: HTTPHeaderName
1351
+ """The "trailer" header."""
1352
+
1353
+ TRANSFER_ENCODING: HTTPHeaderName
1354
+ """The "transfer-encoding" header."""
1355
+
1356
+ USER_AGENT: HTTPHeaderName
1357
+ """The "user-agent" header."""
1358
+
1359
+ UPGRADE: HTTPHeaderName
1360
+ """The "upgrade" header."""
1361
+
1362
+ UPGRADE_INSECURE_REQUESTS: HTTPHeaderName
1363
+ """The "upgrade-insecure-requests" header."""
1364
+
1365
+ VARY: HTTPHeaderName
1366
+ """The "vary" header."""
1367
+
1368
+ VIA: HTTPHeaderName
1369
+ """The "via" header."""
1370
+
1371
+ WARNING: HTTPHeaderName
1372
+ """The "warning" header."""
1373
+
1374
+ WWW_AUTHENTICATE: HTTPHeaderName
1375
+ """The "www-authenticate" header."""
1376
+
1377
+ X_CONTENT_TYPE_OPTIONS: HTTPHeaderName
1378
+ """The "x-content-type-options" header."""
1379
+
1380
+ X_DNS_PREFETCH_CONTROL: HTTPHeaderName
1381
+ """The "x-dns-prefetch-control" header."""
1382
+
1383
+ X_FRAME_OPTIONS: HTTPHeaderName
1384
+ """The "x-frame-options" header."""
1385
+
1386
+ X_XSS_PROTECTION: HTTPHeaderName
1387
+ """The "x-xss-protection" header."""
1388
+
1389
+ def set_sync_timeout(timeout: float) -> AbstractContextManager[None]: ...
1390
+ def get_sync_timeout() -> datetime.timedelta | None: ...