rnet 3.0.0rc1__cp311-abi3-macosx_10_12_x86_64.whl → 3.0.0rc3__cp311-abi3-macosx_10_12_x86_64.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.

Potentially problematic release.


This version of rnet might be problematic. Click here for more details.

rnet/__init__.pyi CHANGED
@@ -23,9 +23,58 @@ try:
23
23
  except ImportError:
24
24
  from typing_extensions import Unpack, NotRequired
25
25
 
26
+ class ClientParams(TypedDict, closed=True):
27
+ emulation: NotRequired[Union[Emulation, EmulationOption]]
28
+ user_agent: NotRequired[str]
29
+ headers: NotRequired[Union[Dict[str, str], HeaderMap]]
30
+ orig_headers: NotRequired[Union[List[str], OrigHeaderMap]]
31
+ referer: NotRequired[bool]
32
+ history: NotRequired[bool]
33
+ allow_redirects: NotRequired[bool]
34
+ max_redirects: NotRequired[int]
35
+ cookie_store: NotRequired[bool]
36
+ cookie_provider: NotRequired[Jar]
37
+ timeout: NotRequired[int]
38
+ connect_timeout: NotRequired[int]
39
+ read_timeout: NotRequired[int]
40
+ tcp_keepalive: NotRequired[int]
41
+ tcp_keepalive_interval: NotRequired[int]
42
+ tcp_keepalive_retries: NotRequired[int]
43
+ tcp_user_timeout: NotRequired[int]
44
+ tcp_nodelay: NotRequired[bool]
45
+ tcp_reuse_address: NotRequired[bool]
46
+ pool_idle_timeout: NotRequired[int]
47
+ pool_max_idle_per_host: NotRequired[int]
48
+ pool_max_size: NotRequired[int]
49
+ http1_only: NotRequired[bool]
50
+ http2_only: NotRequired[bool]
51
+ https_only: NotRequired[bool]
52
+ http2_max_retry_count: NotRequired[int]
53
+ verify: NotRequired[Union[bool, Path, CertStore]]
54
+ identity: NotRequired[Identity]
55
+ keylog: NotRequired[KeyLogPolicy]
56
+ tls_info: NotRequired[bool]
57
+ min_tls_version: NotRequired[TlsVersion]
58
+ max_tls_version: NotRequired[TlsVersion]
59
+ no_proxy: NotRequired[bool]
60
+ proxies: NotRequired[List[Proxy]]
61
+ local_address: NotRequired[Union[str, ipaddress.IPv4Address, ipaddress.IPv6Address]]
62
+ interface: NotRequired[str]
63
+ gzip: NotRequired[bool]
64
+ brotli: NotRequired[bool]
65
+ deflate: NotRequired[bool]
66
+ zstd: NotRequired[bool]
67
+
68
+ class ProxyParams(TypedDict, closed=True):
69
+ username: NotRequired[str]
70
+ password: NotRequired[str]
71
+ custom_http_auth: NotRequired[str]
72
+ custom_http_headers: NotRequired[Union[Dict[str, str], HeaderMap]]
73
+ exclusion: NotRequired[str]
74
+
26
75
  class Request(TypedDict, closed=True):
27
76
  emulation: NotRequired[Union[Emulation, EmulationOption]]
28
- proxy: NotRequired[Union[str, Proxy]]
77
+ proxy: NotRequired[Proxy]
29
78
  local_address: NotRequired[Union[ipaddress.IPv4Address, ipaddress.IPv6Address]]
30
79
  interface: NotRequired[str]
31
80
  timeout: NotRequired[int]
@@ -59,7 +108,7 @@ class Request(TypedDict, closed=True):
59
108
 
60
109
  class WebSocketRequest(TypedDict, closed=True):
61
110
  emulation: NotRequired[Union[Emulation, EmulationOption]]
62
- proxy: NotRequired[Union[str, Proxy]]
111
+ proxy: NotRequired[Proxy]
63
112
  local_address: NotRequired[Union[str, ipaddress.IPv4Address, ipaddress.IPv6Address]]
64
113
  interface: NotRequired[str]
65
114
  headers: NotRequired[Union[Dict[str, str], HeaderMap]]
@@ -79,62 +128,14 @@ class WebSocketRequest(TypedDict, closed=True):
79
128
  max_frame_size: NotRequired[int]
80
129
  accept_unmasked_frames: NotRequired[bool]
81
130
 
82
- class ProxyParams(TypedDict, closed=True):
83
- username: NotRequired[str]
84
- password: NotRequired[str]
85
- custom_http_auth: NotRequired[str]
86
- custom_http_headers: NotRequired[Union[Dict[str, str], HeaderMap]]
87
- exclusion: NotRequired[str]
88
-
89
131
  class Client:
90
132
  r"""
91
133
  A client for making HTTP requests.
92
134
  """
93
135
 
94
- def __new__(
136
+ def __init__(
95
137
  cls,
96
- emulation: Optional[Union[Emulation, EmulationOption]] = None,
97
- user_agent: Optional[str] = None,
98
- headers: Optional[Union[Dict[str, str], HeaderMap]] = None,
99
- orig_headers: Optional[Union[List[str], OrigHeaderMap]] = None,
100
- referer: Optional[bool] = None,
101
- allow_redirects: Optional[bool] = None,
102
- max_redirects: Optional[int] = None,
103
- cookie_store: Optional[bool] = None,
104
- cookie_provider: Optional[Jar] = None,
105
- timeout: Optional[int] = None,
106
- connect_timeout: Optional[int] = None,
107
- read_timeout: Optional[int] = None,
108
- no_keepalive: Optional[bool] = None,
109
- tcp_keepalive: Optional[int] = None,
110
- tcp_keepalive_interval: Optional[int] = None,
111
- tcp_keepalive_retries: Optional[int] = None,
112
- tcp_user_timeout: Optional[int] = None,
113
- tcp_nodelay: Optional[bool] = None,
114
- tcp_reuse_address: Optional[bool] = None,
115
- pool_idle_timeout: Optional[int] = None,
116
- pool_max_idle_per_host: Optional[int] = None,
117
- pool_max_size: Optional[int] = None,
118
- http1_only: Optional[bool] = None,
119
- http2_only: Optional[bool] = None,
120
- https_only: Optional[bool] = None,
121
- http2_max_retry_count: Optional[int] = None,
122
- verify: Optional[Union[bool, Path, CertStore]] = None,
123
- identity: Optional[Identity] = None,
124
- keylog: Optional[KeyLogPolicy] = None,
125
- tls_info: Optional[bool] = None,
126
- min_tls_version: Optional[TlsVersion] = None,
127
- max_tls_version: Optional[TlsVersion] = None,
128
- no_proxy: Optional[bool] = None,
129
- proxies: Optional[List[Proxy]] = None,
130
- local_address: Optional[
131
- Union[str, ipaddress.IPv4Address, ipaddress.IPv6Address]
132
- ] = None,
133
- interface: Optional[str] = None,
134
- gzip: Optional[bool] = None,
135
- brotli: Optional[bool] = None,
136
- deflate: Optional[bool] = None,
137
- zstd: Optional[bool] = None,
138
+ **kwargs: Unpack[ClientParams],
138
139
  ) -> Client:
139
140
  r"""
140
141
  Creates a new Client instance.
@@ -152,7 +153,6 @@ class Client:
152
153
  timeout: Total timeout (seconds).
153
154
  connect_timeout: Connection timeout (seconds).
154
155
  read_timeout: Read timeout (seconds).
155
- no_keepalive: Disable HTTP keep-alive.
156
156
  tcp_keepalive: TCP keepalive time (seconds).
157
157
  tcp_keepalive_interval: TCP keepalive interval (seconds).
158
158
  tcp_keepalive_retries: TCP keepalive retry count.
@@ -444,7 +444,7 @@ class Multipart:
444
444
  A multipart form for a request.
445
445
  """
446
446
 
447
- def __new__(cls, *parts) -> Multipart:
447
+ def __init__(cls, *parts) -> Multipart:
448
448
  r"""
449
449
  Creates a new multipart form.
450
450
  """
@@ -454,7 +454,7 @@ class Part:
454
454
  A part of a multipart form.
455
455
  """
456
456
 
457
- def __new__(
457
+ def __init__(
458
458
  cls,
459
459
  name: str,
460
460
  value: Union[
@@ -507,51 +507,62 @@ class Response:
507
507
 
508
508
  url: str
509
509
  r"""
510
- Returns the URL of the response.
510
+ Get the URL of the response.
511
511
  """
512
+
512
513
  status: StatusCode
513
514
  r"""
514
- Returns the status code of the response.
515
+ Get the status code of the response.
515
516
  """
517
+
516
518
  version: Version
517
519
  r"""
518
- Returns the HTTP version of the response.
520
+ Get the HTTP version of the response.
519
521
  """
522
+
520
523
  headers: HeaderMap
521
524
  r"""
522
- Returns the headers of the response.
525
+ Get the headers of the response.
523
526
  """
527
+
524
528
  cookies: List[Cookie]
525
529
  r"""
526
- Returns the cookies of the response.
530
+ Get the cookies of the response.
527
531
  """
532
+
528
533
  content_length: int
529
534
  r"""
530
- Returns the content length of the response.
535
+ Get the content length of the response.
531
536
  """
537
+
532
538
  remote_addr: Optional[SocketAddr]
533
539
  r"""
534
- Returns the remote address of the response.
540
+ Get the remote address of the response.
535
541
  """
536
- encoding: str
542
+
543
+ local_addr: Optional[SocketAddr]
537
544
  r"""
538
- Encoding to decode with when accessing text.
545
+ Get the local address of the response.
546
+ """
547
+
548
+ history: List[History]
549
+ r"""
550
+ Get the redirect history of the Response.
551
+ """
552
+
553
+ peer_certificate: Optional[bytes]
554
+ r"""
555
+ Get the DER encoded leaf certificate of the response.
539
556
  """
540
- def __aenter__(self) -> Any: ...
541
- def __aexit__(self, _exc_type: Any, _exc_value: Any, _traceback: Any) -> Any: ...
542
- def peer_certificate(self) -> Optional[bytes]:
543
- r"""
544
- Returns the TLS peer certificate of the response.
545
- """
546
557
 
547
558
  async def text(self) -> str:
548
559
  r"""
549
- Returns the text content of the response.
560
+ Get the text content of the response.
550
561
  """
551
562
 
552
563
  async def text_with_charset(self, encoding: str) -> str:
553
564
  r"""
554
- Returns the text content of the response with a specific charset.
565
+ Get the text content of the response with a specific charset.
555
566
 
556
567
  # Arguments
557
568
 
@@ -560,24 +571,48 @@ class Response:
560
571
 
561
572
  async def json(self) -> Any:
562
573
  r"""
563
- Returns the JSON content of the response.
574
+ Get the JSON content of the response.
564
575
  """
565
576
 
566
577
  async def bytes(self) -> bytes:
567
578
  r"""
568
- Returns the bytes content of the response.
579
+ Get the bytes content of the response.
569
580
  """
570
581
 
571
582
  def stream(self) -> Streamer:
572
583
  r"""
573
- Convert the response into a `Stream` of `Bytes` from the body.
584
+ Get the response into a `Stream` of `Bytes` from the body.
574
585
  """
575
586
 
576
587
  async def close(self) -> None:
577
588
  r"""
578
- Closes the response connection.
589
+ Close the response connection.
579
590
  """
580
591
 
592
+ async def __aenter__(self) -> Any: ...
593
+ async def __aexit__(
594
+ self, _exc_type: Any, _exc_value: Any, _traceback: Any
595
+ ) -> Any: ...
596
+
597
+ class History:
598
+ """
599
+ An entry in the redirect history.
600
+ """
601
+
602
+ status: int
603
+ """Get the status code of the redirect response."""
604
+
605
+ url: str
606
+ """Get the URL of the redirect response."""
607
+
608
+ previous: str
609
+ """Get the previous URL before the redirect response."""
610
+
611
+ headers: HeaderMap
612
+ """Get the headers of the redirect response."""
613
+
614
+ def __str__(self) -> str: ...
615
+
581
616
  class SocketAddr:
582
617
  r"""
583
618
  A IP socket address.
@@ -647,14 +682,6 @@ class Streamer:
647
682
 
648
683
  async def main():
649
684
  resp = await rnet.get("https://httpbin.org/stream/20")
650
- print("Status Code: ", resp.status)
651
- print("Version: ", resp.version)
652
- print("Response URL: ", resp.url)
653
- print("Headers: ", resp.headers)
654
- print("Content-Length: ", resp.content_length)
655
- print("Encoding: ", resp.encoding)
656
- print("Remote Address: ", resp.remote_addr)
657
-
658
685
  async with resp.stream() as streamer:
659
686
  async for chunk in streamer:
660
687
  print("Chunk: ", chunk)
@@ -665,12 +692,14 @@ class Streamer:
665
692
  ```
666
693
  """
667
694
 
668
- def __aiter__(self) -> Streamer: ...
669
- def __anext__(self) -> Any: ...
670
- def __aenter__(self) -> Any: ...
671
- def __aexit__(self, _exc_type: Any, _exc_value: Any, _traceback: Any) -> Any: ...
695
+ async def __aiter__(self) -> Streamer: ...
696
+ async def __anext__(self) -> Optional[bytes]: ...
697
+ async def __aenter__(self) -> Any: ...
698
+ async def __aexit__(
699
+ self, _exc_type: Any, _exc_value: Any, _traceback: Any
700
+ ) -> Any: ...
672
701
  def __iter__(self) -> Streamer: ...
673
- def __next__(self) -> Any: ...
702
+ def __next__(self) -> bytes: ...
674
703
  def __enter__(self) -> Streamer: ...
675
704
  def __exit__(self, _exc_type: Any, _exc_value: Any, _traceback: Any) -> None: ...
676
705
 
@@ -1094,33 +1123,34 @@ class WebSocket:
1094
1123
 
1095
1124
  status: StatusCode
1096
1125
  r"""
1097
- Returns the status code of the response.
1126
+ Get the status code of the response.
1098
1127
  """
1099
1128
  version: Version
1100
1129
  r"""
1101
- Returns the HTTP version of the response.
1130
+ Get the HTTP version of the response.
1102
1131
  """
1103
1132
  headers: HeaderMap
1104
1133
  r"""
1105
- Returns the headers of the response.
1134
+ Get the headers of the response.
1106
1135
  """
1107
1136
  cookies: List[Cookie]
1108
1137
  r"""
1109
- Returns the cookies of the response.
1138
+ Get the cookies of the response.
1110
1139
  """
1111
1140
  remote_addr: Optional[SocketAddr]
1112
1141
  r"""
1113
- Returns the remote address of the response.
1142
+ Get the remote address of the response.
1114
1143
  """
1115
1144
  protocol: Optional[str]
1116
1145
  r"""
1117
- Returns the WebSocket protocol.
1146
+ Get the WebSocket protocol.
1118
1147
  """
1119
- def __aiter__(self) -> WebSocket: ...
1120
- def __anext__(self) -> Any: ...
1148
+
1121
1149
  def __aenter__(self) -> Any: ...
1122
1150
  def __aexit__(self, _exc_type: Any, _exc_value: Any, _traceback: Any) -> Any: ...
1123
- async def recv(self) -> Optional[Message]:
1151
+ async def recv(
1152
+ self, timeout: datetime.timedelta | None = None
1153
+ ) -> Optional[Message]:
1124
1154
  r"""
1125
1155
  Receives a message from the WebSocket.
1126
1156
  """
rnet/blocking.py CHANGED
@@ -1,21 +1,15 @@
1
- from typing import Unpack
2
- from rnet import Message, Proxy, Request, Streamer, WebSocketRequest
3
- import ipaddress
1
+ import datetime
2
+ from rnet import ClientParams, History, Message, Request, Streamer, WebSocketRequest
4
3
  from typing import (
5
4
  Optional,
6
- Union,
7
5
  Any,
8
- Dict,
9
6
  List,
10
7
  Unpack,
11
8
  )
12
- from pathlib import Path
13
9
 
14
10
  from rnet import Version, Method, SocketAddr, StatusCode
15
- from rnet.tls import CertStore, KeyLogPolicy, TlsVersion, Identity
16
- from rnet.header import HeaderMap, OrigHeaderMap
17
- from rnet.cookie import Cookie, Jar
18
- from rnet.emulation import EmulationOption, Emulation
11
+ from rnet.header import HeaderMap
12
+ from rnet.cookie import Cookie
19
13
 
20
14
 
21
15
  class Client:
@@ -23,50 +17,9 @@ class Client:
23
17
  A blocking client for making HTTP requests.
24
18
  """
25
19
 
26
- def __new__(
20
+ def __init__(
27
21
  cls,
28
- emulation: Optional[Union[Emulation, EmulationOption]] = None,
29
- user_agent: Optional[str] = None,
30
- headers: Optional[Union[Dict[str, str], HeaderMap]] = None,
31
- orig_headers: Optional[Union[List[str], OrigHeaderMap]] = None,
32
- referer: Optional[bool] = None,
33
- allow_redirects: Optional[bool] = None,
34
- max_redirects: Optional[int] = None,
35
- cookie_store: Optional[bool] = None,
36
- cookie_provider: Optional[Jar] = None,
37
- timeout: Optional[int] = None,
38
- connect_timeout: Optional[int] = None,
39
- read_timeout: Optional[int] = None,
40
- no_keepalive: Optional[bool] = None,
41
- tcp_keepalive: Optional[int] = None,
42
- tcp_keepalive_interval: Optional[int] = None,
43
- tcp_keepalive_retries: Optional[int] = None,
44
- tcp_user_timeout: Optional[int] = None,
45
- tcp_nodelay: Optional[bool] = None,
46
- tcp_reuse_address: Optional[bool] = None,
47
- pool_idle_timeout: Optional[int] = None,
48
- pool_max_idle_per_host: Optional[int] = None,
49
- pool_max_size: Optional[int] = None,
50
- http1_only: Optional[bool] = None,
51
- http2_only: Optional[bool] = None,
52
- https_only: Optional[bool] = None,
53
- http2_max_retry_count: Optional[int] = None,
54
- verify: Optional[Union[bool, Path, CertStore]] = None,
55
- identity: Optional[Identity] = None,
56
- keylog: Optional[KeyLogPolicy] = None,
57
- tls_info: Optional[bool] = None,
58
- min_tls_version: Optional[TlsVersion] = None,
59
- max_tls_version: Optional[TlsVersion] = None,
60
- no_proxy: Optional[bool] = None,
61
- proxies: Optional[List[Proxy]] = None,
62
- local_address: Optional[
63
- Union[str, ipaddress.IPv4Address, ipaddress.IPv6Address]
64
- ] = None,
65
- interface: Optional[str] = None,
66
- gzip: Optional[bool] = None,
67
- brotli: Optional[bool] = None,
68
- deflate: Optional[bool] = None,
69
- zstd: Optional[bool] = None,
22
+ **kwargs: Unpack[ClientParams],
70
23
  ) -> "Client":
71
24
  r"""
72
25
  Creates a new blocking Client instance.
@@ -84,7 +37,6 @@ class Client:
84
37
  timeout: Total timeout (seconds).
85
38
  connect_timeout: Connection timeout (seconds).
86
39
  read_timeout: Read timeout (seconds).
87
- no_keepalive: Disable HTTP keep-alive.
88
40
  tcp_keepalive: TCP keepalive time (seconds).
89
41
  tcp_keepalive_interval: TCP keepalive interval (seconds).
90
42
  tcp_keepalive_retries: TCP keepalive retry count.
@@ -375,52 +327,62 @@ class Response:
375
327
 
376
328
  url: str
377
329
  r"""
378
- Returns the URL of the response.
330
+ Get the URL of the response.
379
331
  """
332
+
380
333
  status: StatusCode
381
334
  r"""
382
- Returns the status code of the response.
335
+ Get the status code of the response.
383
336
  """
337
+
384
338
  version: Version
385
339
  r"""
386
- Returns the HTTP version of the response.
340
+ Get the HTTP version of the response.
387
341
  """
342
+
388
343
  headers: HeaderMap
389
344
  r"""
390
- Returns the headers of the response.
345
+ Get the headers of the response.
391
346
  """
347
+
392
348
  cookies: List[Cookie]
393
349
  r"""
394
- Returns the cookies of the response.
350
+ Get the cookies of the response.
395
351
  """
352
+
396
353
  content_length: int
397
354
  r"""
398
- Returns the content length of the response.
355
+ Get the content length of the response.
399
356
  """
357
+
400
358
  remote_addr: Optional[SocketAddr]
401
359
  r"""
402
- Returns the remote address of the response.
360
+ Get the remote address of the response.
403
361
  """
404
- encoding: str
362
+
363
+ local_addr: Optional[SocketAddr]
405
364
  r"""
406
- Encoding to decode with when accessing text.
365
+ Get the local address of the response.
407
366
  """
408
367
 
409
- def __enter__(self) -> "Response": ...
410
- def __exit__(self, _exc_type: Any, _exc_value: Any, _traceback: Any) -> None: ...
411
- def peer_certificate(self) -> Optional[bytes]:
412
- r"""
413
- Returns the TLS peer certificate of the response.
414
- """
368
+ history: List[History]
369
+ r"""
370
+ Get the redirect history of the Response.
371
+ """
372
+
373
+ peer_certificate: Optional[bytes]
374
+ r"""
375
+ Get the DER encoded leaf certificate of the response.
376
+ """
415
377
 
416
378
  def text(self) -> str:
417
379
  r"""
418
- Returns the text content of the response.
380
+ Get the text content of the response.
419
381
  """
420
382
 
421
383
  def text_with_charset(self, encoding: str) -> str:
422
384
  r"""
423
- Returns the text content of the response with a specific charset.
385
+ Get the text content of the response with a specific charset.
424
386
 
425
387
  # Arguments
426
388
 
@@ -429,24 +391,27 @@ class Response:
429
391
 
430
392
  def json(self) -> Any:
431
393
  r"""
432
- Returns the JSON content of the response.
394
+ Get the JSON content of the response.
433
395
  """
434
396
 
435
397
  def bytes(self) -> bytes:
436
398
  r"""
437
- Returns the bytes content of the response.
399
+ Get the bytes content of the response.
438
400
  """
439
401
 
440
402
  def stream(self) -> Streamer:
441
403
  r"""
442
- Convert the response into a `Stream` of `Bytes` from the body.
404
+ Get the response into a `Stream` of `Bytes` from the body.
443
405
  """
444
406
 
445
407
  def close(self) -> None:
446
408
  r"""
447
- Closes the response connection.
409
+ Close the response connection.
448
410
  """
449
411
 
412
+ def __enter__(self) -> "Response": ...
413
+ def __exit__(self, _exc_type: Any, _exc_value: Any, _traceback: Any) -> None: ...
414
+
450
415
 
451
416
  class WebSocket:
452
417
  r"""
@@ -455,34 +420,33 @@ class WebSocket:
455
420
 
456
421
  status: StatusCode
457
422
  r"""
458
- Returns the status code of the response.
423
+ Get the status code of the response.
459
424
  """
460
425
  version: Version
461
426
  r"""
462
- Returns the HTTP version of the response.
427
+ Get the HTTP version of the response.
463
428
  """
464
429
  headers: HeaderMap
465
430
  r"""
466
- Returns the headers of the response.
431
+ Get the headers of the response.
467
432
  """
468
433
  cookies: List[Cookie]
469
434
  r"""
470
- Returns the cookies of the response.
435
+ Get the cookies of the response.
471
436
  """
472
437
  remote_addr: Optional[SocketAddr]
473
438
  r"""
474
- Returns the remote address of the response.
439
+ Get the remote address of the response.
475
440
  """
476
441
  protocol: Optional[str]
477
442
  r"""
478
- Returns the WebSocket protocol.
443
+ Get the WebSocket protocol.
479
444
  """
480
445
 
481
- def __iter__(self) -> "WebSocket": ...
482
- def __next__(self) -> Message: ...
483
446
  def __enter__(self) -> "WebSocket": ...
484
447
  def __exit__(self, _exc_type: Any, _exc_value: Any, _traceback: Any) -> None: ...
485
- def recv(self) -> Optional[Message]:
448
+
449
+ def recv(self, timeout: datetime.timedelta | None = None) -> Optional[Message]:
486
450
  r"""
487
451
  Receives a message from the WebSocket.
488
452
  """
rnet/cookie.py CHANGED
@@ -8,7 +8,7 @@ and provides a cookie jar for automatic cookie handling during HTTP requests.
8
8
 
9
9
  import datetime
10
10
  from enum import Enum, auto
11
- from typing import Optional
11
+ from typing import List, Optional
12
12
 
13
13
 
14
14
  class SameSite(Enum):
@@ -67,17 +67,17 @@ class Cookie:
67
67
  The cookie expiration time.
68
68
  """
69
69
 
70
- def __new__(
70
+ def __init__(
71
71
  cls,
72
72
  name: str,
73
73
  value: str,
74
- domain: Optional[str] = None,
75
- path: Optional[str] = None,
76
- max_age: Optional[datetime.timedelta] = None,
77
- expires: Optional[datetime.datetime] = None,
74
+ domain: str | None = None,
75
+ path: str | None = None,
76
+ max_age: datetime.timedelta | None = None,
77
+ expires: datetime.datetime | None = None,
78
78
  http_only: bool = False,
79
79
  secure: bool = False,
80
- same_site: Optional[SameSite] = None,
80
+ same_site: SameSite | None = None,
81
81
  ) -> "Cookie":
82
82
  r"""
83
83
  Create a new cookie.
@@ -94,7 +94,7 @@ class Jar:
94
94
  to automatically handle cookies during HTTP requests and responses.
95
95
  """
96
96
 
97
- def __new__(cls) -> "Jar":
97
+ def __init__(cls) -> "Jar":
98
98
  r"""
99
99
  Create a new cookie jar.
100
100
  """
@@ -104,12 +104,12 @@ class Jar:
104
104
  Get a cookie by name and URL.
105
105
  """
106
106
 
107
- def get_all(self) -> list[Cookie]:
107
+ def get_all(self) -> List[Cookie]:
108
108
  r"""
109
109
  Get all cookies.
110
110
  """
111
111
 
112
- def add(self, cookie: Cookie, url: str) -> None:
112
+ def add_cookie(self, cookie: Cookie, url: str) -> None:
113
113
  r"""
114
114
  Add a cookie to this jar.
115
115
  """
rnet/emulation.py CHANGED
@@ -11,7 +11,6 @@ authentic and less likely to be blocked by anti-bot systems.
11
11
  """
12
12
 
13
13
  from enum import Enum, auto
14
- from typing import Optional
15
14
 
16
15
 
17
16
  class Emulation(Enum):
@@ -131,12 +130,12 @@ class EmulationOption:
131
130
  browser types with specific operating systems.
132
131
  """
133
132
 
134
- def __new__(
133
+ def __init__(
135
134
  cls,
136
135
  emulation: Emulation,
137
- emulation_os: Optional[EmulationOS] = None,
138
- skip_http2: Optional[bool] = None,
139
- skip_headers: Optional[bool] = None,
136
+ emulation_os: EmulationOS | None = None,
137
+ skip_http2: bool | None = None,
138
+ skip_headers: bool | None = None,
140
139
  ) -> "EmulationOption":
141
140
  """
142
141
  Create a new emulation configuration.
rnet/header.py CHANGED
@@ -11,7 +11,7 @@ including proper support for headers that can have multiple values (like
11
11
  Set-Cookie, Accept-Encoding, etc.).
12
12
  """
13
13
 
14
- from typing import List, Optional, Tuple
14
+ from typing import Iterator, List, Optional, Tuple
15
15
 
16
16
 
17
17
  class HeaderMap:
@@ -47,15 +47,15 @@ class HeaderMap:
47
47
  """Return the total number of header values (not unique names)."""
48
48
  ...
49
49
 
50
- def __iter__(self) -> "HeaderMapKeysIter":
51
- """Iterate over unique header names."""
50
+ def __iter__(self) -> Iterator[Tuple[bytes, bytes]]:
51
+ """Iterate all header(name, value) pairs, including duplicates for multiple values."""
52
52
  ...
53
53
 
54
54
  def __str__(self) -> str:
55
55
  """Return a string representation of all headers."""
56
56
  ...
57
57
 
58
- def __new__(
58
+ def __init__(
59
59
  cls, init: Optional[dict] = None, capacity: Optional[int] = None
60
60
  ) -> "HeaderMap":
61
61
  """
@@ -108,12 +108,6 @@ class HeaderMap:
108
108
  Args:
109
109
  key: The header name (case-insensitive)
110
110
  value: The header value to set
111
-
112
- Example:
113
- ```python
114
- headers.insert('Content-Type', 'application/json')
115
- # Replaces any existing Content-Type header
116
- ```
117
111
  """
118
112
 
119
113
  def append(self, key: str, value: str) -> None:
@@ -127,13 +121,6 @@ class HeaderMap:
127
121
  Args:
128
122
  key: The header name (case-insensitive)
129
123
  value: The header value to append
130
-
131
- Example:
132
- ```python
133
- headers.append('Accept-Encoding', 'gzip')
134
- headers.append('Accept-Encoding', 'deflate')
135
- # Results in: Accept-Encoding: gzip, deflate
136
- ```
137
124
  """
138
125
 
139
126
  def remove(self, key: str) -> None:
@@ -161,15 +148,9 @@ class HeaderMap:
161
148
 
162
149
  Returns:
163
150
  The first header value as bytes, or the default value
164
-
165
- Example:
166
- ```python
167
- content_type = headers.get('Content-Type', b'text/plain')
168
- auth = headers.get('Authorization') # Returns None if missing
169
- ```
170
151
  """
171
152
 
172
- def get_all(self, key: str) -> "HeaderMapValuesIter":
153
+ def get_all(self, key: str) -> Iterator[bytes]:
173
154
  r"""
174
155
  Get all values for a header name.
175
156
 
@@ -182,16 +163,22 @@ class HeaderMap:
182
163
 
183
164
  Returns:
184
165
  An iterator over all header values
166
+ """
185
167
 
186
- Example:
187
- ```python
188
- # Get all Set-Cookie headers
189
- cookies = list(headers.get_all('Set-Cookie'))
168
+ def values(self) -> Iterator[bytes]:
169
+ """
170
+ Iterate over all header values.
190
171
 
191
- # Process multiple Accept-Encoding values
192
- for encoding in headers.get_all('Accept-Encoding'):
193
- print(f"Accepts: {encoding.decode()}")
194
- ```
172
+ Returns:
173
+ An iterator over all header values as bytes.
174
+ """
175
+
176
+ def keys(self) -> Iterator[bytes]:
177
+ """
178
+ Iterate over unique header names.
179
+
180
+ Returns:
181
+ An iterator over unique header names as bytes.
195
182
  """
196
183
 
197
184
  def len(self) -> int:
@@ -233,24 +220,6 @@ class HeaderMap:
233
220
  is_empty() will return True.
234
221
  """
235
222
 
236
- def items(self) -> "HeaderMapItemsIter":
237
- r"""
238
- Get an iterator over all header name-value pairs.
239
-
240
- Returns an iterator that yields tuples of (name, value) for each
241
- header value. Headers with multiple values will appear multiple
242
- times with different values.
243
-
244
- Returns:
245
- Iterator over (name, value) tuples
246
-
247
- Example:
248
- ```python
249
- for name, value in headers.items():
250
- print(f"{name.decode()}: {value.decode()}")
251
- ```
252
- """
253
-
254
223
 
255
224
  class OrigHeaderMap:
256
225
  """
@@ -294,33 +263,7 @@ class OrigHeaderMap:
294
263
  """
295
264
  ...
296
265
 
297
- def insert(self, value: str) -> bool:
298
- """
299
- Insert a new header name into the collection.
300
-
301
- If the map did not previously have this key present, then False is returned.
302
- If the map did have this key present, the new value is pushed to the end
303
- of the list of values currently associated with the key. The key is not
304
- updated, though; this matters for types that can be == without being identical.
305
-
306
- Args:
307
- value: The header name to insert.
308
-
309
- Returns:
310
- True if the key was newly inserted, False if it already existed.
311
- """
312
- ...
313
-
314
- def extend(self, other: "OrigHeaderMap") -> None:
315
- """
316
- Extends the map with all entries from another OrigHeaderMap, preserving order.
317
-
318
- Args:
319
- other: Another OrigHeaderMap to extend from.
320
- """
321
- ...
322
-
323
- def items(self) -> "OrigHeaderMapIter":
266
+ def __iter__(self) -> Iterator[Tuple[bytes, bytes]]:
324
267
  """
325
268
  Returns an iterator over the (standard_name, original_name) pairs.
326
269
 
@@ -335,97 +278,28 @@ class OrigHeaderMap:
335
278
  """
336
279
  ...
337
280
 
338
-
339
- class HeaderMapItemsIter:
340
- r"""
341
- Iterator over header name-value pairs in a HeaderMap.
342
-
343
- Yields tuples of (header_name, header_value) where both are bytes.
344
- Headers with multiple values will appear as separate tuples.
345
- """
346
-
347
- def __iter__(self) -> "HeaderMapItemsIter":
348
- """Return self as iterator."""
349
- ...
350
-
351
- def __next__(self) -> Optional[Tuple[bytes, bytes]]:
352
- """
353
- Get the next header name-value pair.
354
-
355
- Returns:
356
- Tuple of (header_name, header_value) or None when exhausted
357
- """
358
- ...
359
-
360
-
361
- class HeaderMapKeysIter:
362
- r"""
363
- Iterator over unique header names in a HeaderMap.
364
-
365
- Yields each unique header name as bytes, regardless of how many
366
- values each header has.
367
- """
368
-
369
- def __iter__(self) -> "HeaderMapKeysIter":
370
- """Return self as iterator."""
371
- ...
372
-
373
- def __next__(self) -> Optional[bytes]:
374
- """
375
- Get the next unique header name.
376
-
377
- Returns:
378
- Header name as bytes, or None when exhausted
281
+ def insert(self, value: str) -> bool:
379
282
  """
380
- ...
381
-
382
-
383
- class HeaderMapValuesIter:
384
- r"""
385
- Iterator over header values in a HeaderMap.
386
-
387
- Yields header values as bytes. When used with get_all(), yields
388
- all values for a specific header name. When used independently,
389
- yields all values in the entire map.
390
- """
283
+ Insert a new header name into the collection.
391
284
 
392
- def __iter__(self) -> "HeaderMapValuesIter":
393
- """Return self as iterator."""
394
- ...
285
+ If the map did not previously have this key present, then False is returned.
286
+ If the map did have this key present, the new value is pushed to the end
287
+ of the list of values currently associated with the key. The key is not
288
+ updated, though; this matters for types that can be == without being identical.
395
289
 
396
- def __next__(self) -> Optional[bytes]:
397
- """
398
- Get the next header value.
290
+ Args:
291
+ value: The header name to insert.
399
292
 
400
293
  Returns:
401
- Header value as bytes, or None when exhausted
402
- """
403
- ...
404
-
405
-
406
- class OrigHeaderMapIter:
407
- """
408
- An iterator over the items in an OrigHeaderMap.
409
-
410
- Yields tuples of (standard_header_name, original_header_name) where:
411
- - standard_header_name is the normalized header name
412
- - original_header_name is the header name as originally received/specified
413
- """
414
-
415
- def __iter__(self) -> "OrigHeaderMapIter":
416
- """
417
- Returns the iterator itself.
294
+ True if the key was newly inserted, False if it already existed.
418
295
  """
419
296
  ...
420
297
 
421
- def __next__(self) -> Tuple[bytes, bytes]:
298
+ def extend(self, other: "OrigHeaderMap") -> None:
422
299
  """
423
- Returns the next (standard_name, original_name) pair.
424
-
425
- Returns:
426
- A tuple of (standard_header_name, original_header_name) as bytes.
300
+ Extends the map with all entries from another OrigHeaderMap, preserving order.
427
301
 
428
- Raises:
429
- StopIteration: When there are no more items.
302
+ Args:
303
+ other: Another OrigHeaderMap to extend from.
430
304
  """
431
305
  ...
rnet/rnet.abi3.so CHANGED
Binary file
rnet/tls.py CHANGED
@@ -8,7 +8,7 @@ These types are typically used to configure client-side TLS authentication and c
8
8
 
9
9
  from enum import Enum, auto
10
10
  from pathlib import Path
11
- from typing import List, Optional
11
+ from typing import List
12
12
 
13
13
 
14
14
  class TlsVersion(Enum):
@@ -62,11 +62,11 @@ class CertStore:
62
62
  Represents a certificate store for verifying TLS connections.
63
63
  """
64
64
 
65
- def __new__(
65
+ def __init__(
66
66
  cls,
67
- der_certs: Optional[List[bytes]] = None,
68
- pem_certs: Optional[List[str]] = None,
69
- default_paths: Optional[bool] = None,
67
+ der_certs: List[bytes] | None = None,
68
+ pem_certs: List[str] | None = None,
69
+ default_paths: bool | None = None,
70
70
  ) -> "CertStore":
71
71
  """
72
72
  Creates a new CertStore.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rnet
3
- Version: 3.0.0rc1
3
+ Version: 3.0.0rc3
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -60,7 +60,7 @@ A blazing-fast Python HTTP client with advanced browser fingerprinting that accu
60
60
  This asynchronous example demonstrates how to make a simple GET request using the `rnet` library. So you need install `rnet` and run the following code:
61
61
 
62
62
  ```bash
63
- pip install asyncio rnet==3.0.0rc1
63
+ pip install asyncio rnet==3.0.0rc3
64
64
  ```
65
65
 
66
66
  And then the code:
@@ -91,7 +91,8 @@ Additional learning resources include:
91
91
  - [DeepWiki](https://deepwiki.com/0x676e67/rnet)
92
92
  - [API Documentation](https://github.com/0x676e67/rnet/blob/main/python/rnet)
93
93
  - [Repository Tests](https://github.com/0x676e67/rnet/tree/main/tests)
94
- - [Repository Examples](https://github.com/0x676e67/rnet/tree/main/python/examples)
94
+ - [Synchronous Examples](https://github.com/0x676e67/rnet/tree/main/python/examples/blocking)
95
+ - [Asynchronous Examples](https://github.com/0x676e67/rnet/tree/main/python/examples)
95
96
 
96
97
  ## Platforms
97
98
 
@@ -0,0 +1,14 @@
1
+ rnet-3.0.0rc3.dist-info/METADATA,sha256=fEfWy3HHnm5piQjMxfjS8tn9XKDwVisWOB3Q9mWNRUU,10143
2
+ rnet-3.0.0rc3.dist-info/WHEEL,sha256=N8W3-0eDM6igWj-H12r7VkxoMaJIqJLxUyWCFstEaGg,105
3
+ rnet-3.0.0rc3.dist-info/licenses/LICENSE,sha256=ryRV02Zq6zAIr1heqDUkcGlpP7gVCDF6AqR4wRa82kI,35153
4
+ rnet/__init__.py,sha256=gqet5qGPHqS1VRr8XjzpQOuYetNn-aLss4lTR7cZ_9M,317
5
+ rnet/__init__.pyi,sha256=udvT5QwB905aczie87n-9BAMePfnzU_yen90CtO-F38,29301
6
+ rnet/blocking.py,sha256=4o6eTsoP0_XboU9JwkVKwPwbo-BtzymmqJnOVRoSdt4,11325
7
+ rnet/cookie.py,sha256=RmkrJ4NXkxapBaa-zP7zJZm-H0TRbYCyAQFtrkvEJAA,2877
8
+ rnet/emulation.py,sha256=JBN1WqW7TrrzRFBxxm6aYYuDfGUfFV8fbWaUiTIBIFA,4993
9
+ rnet/exceptions.py,sha256=pr8RNPhr_CswkdKgZGvamSFwyrHE6OPQk72YcJACNBo,5906
10
+ rnet/header.py,sha256=70Ro2nLV0QJgYARpatFcKJhx3NvxrYpdv6T9WMAu82E,9559
11
+ rnet/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ rnet/rnet.abi3.so,sha256=batcsghygmSIJSEwGudaSNTM2s18dSytSRIflMq6h1o,8350600
13
+ rnet/tls.py,sha256=lbte5JDU9_mcPY62H3zV5aC5sPc9v4vRSf9tMrucROA,4793
14
+ rnet-3.0.0rc3.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: maturin (1.9.3)
2
+ Generator: maturin (1.9.4)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp311-abi3-macosx_10_12_x86_64
@@ -1,14 +0,0 @@
1
- rnet-3.0.0rc1.dist-info/METADATA,sha256=I7WMxAsKWF5uU6WfLht1LeD4N-mMvAc3XGQ6p-FvDkw,10047
2
- rnet-3.0.0rc1.dist-info/WHEEL,sha256=f7YMmFV7_oMXWzGFklHTONXU-Nc4CauArX_2rsvdYdw,105
3
- rnet-3.0.0rc1.dist-info/licenses/LICENSE,sha256=ryRV02Zq6zAIr1heqDUkcGlpP7gVCDF6AqR4wRa82kI,35153
4
- rnet/__init__.py,sha256=gqet5qGPHqS1VRr8XjzpQOuYetNn-aLss4lTR7cZ_9M,317
5
- rnet/__init__.pyi,sha256=g74_wT2p_7-TGKTYr5xSoDCxFkn34OU1Glz4UzTnGW8,29521
6
- rnet/blocking.py,sha256=Xo8CwyuhyEd-k6D88nbTIB1aLb-wUbDZNy2-AaXcdrw,13536
7
- rnet/cookie.py,sha256=fN8V-OKr-LT3psv9XTvHfnPD8Nwp10Awxxg762ScwP0,2877
8
- rnet/emulation.py,sha256=i3Qv1-c0wtWgxJ_hOlS6AFjNDIO4GsSP2SvRONRS6FI,5029
9
- rnet/exceptions.py,sha256=pr8RNPhr_CswkdKgZGvamSFwyrHE6OPQk72YcJACNBo,5906
10
- rnet/header.py,sha256=xbBb0wWKZRUs2ylldU_sN13QYBUDvZ-3zynCBd4UiYs,12955
11
- rnet/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- rnet/rnet.abi3.so,sha256=VyiLGA0RiMM8_nLrJlqgJsEeP8L91frmdatT4a0zByk,8303376
13
- rnet/tls.py,sha256=Ko0h58k3twVyycuqK7zgBtN3JLnhZ8oDUZqANJshEDE,4811
14
- rnet-3.0.0rc1.dist-info/RECORD,,