rnet 3.0.0rc3__cp311-abi3-win_amd64.whl → 3.0.0rc5__cp311-abi3-win_amd64.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/blocking.py CHANGED
@@ -1,5 +1,16 @@
1
1
  import datetime
2
- from rnet import ClientParams, History, Message, Request, Streamer, WebSocketRequest
2
+ from rnet import (
3
+ ClientParams,
4
+ History,
5
+ Message,
6
+ Request,
7
+ Streamer,
8
+ WebSocketRequest,
9
+ Version,
10
+ Method,
11
+ SocketAddr,
12
+ StatusCode,
13
+ )
3
14
  from typing import (
4
15
  Optional,
5
16
  Any,
@@ -7,64 +18,191 @@ from typing import (
7
18
  Unpack,
8
19
  )
9
20
 
10
- from rnet import Version, Method, SocketAddr, StatusCode
11
21
  from rnet.header import HeaderMap
12
22
  from rnet.cookie import Cookie
13
23
 
14
24
 
25
+ class Response:
26
+ r"""
27
+ A blocking response from a request.
28
+ """
29
+
30
+ url: str
31
+ r"""
32
+ Get the URL of the response.
33
+ """
34
+
35
+ status: StatusCode
36
+ r"""
37
+ Get the status code of the response.
38
+ """
39
+
40
+ version: Version
41
+ r"""
42
+ Get the HTTP version of the response.
43
+ """
44
+
45
+ headers: HeaderMap
46
+ r"""
47
+ Get the headers of the response.
48
+ """
49
+
50
+ cookies: List[Cookie]
51
+ r"""
52
+ Get the cookies of the response.
53
+ """
54
+
55
+ content_length: Optional[int]
56
+ r"""
57
+ Get the content length of the response.
58
+ """
59
+
60
+ remote_addr: Optional[SocketAddr]
61
+ r"""
62
+ Get the remote address of the response.
63
+ """
64
+
65
+ local_addr: Optional[SocketAddr]
66
+ r"""
67
+ Get the local address of the response.
68
+ """
69
+
70
+ history: List[History]
71
+ r"""
72
+ Get the redirect history of the Response.
73
+ """
74
+
75
+ peer_certificate: Optional[bytes]
76
+ r"""
77
+ Get the DER encoded leaf certificate of the response.
78
+ """
79
+
80
+ def text(self) -> str:
81
+ r"""
82
+ Get the text content of the response.
83
+ """
84
+ ...
85
+
86
+ def text_with_charset(self, encoding: str) -> str:
87
+ r"""
88
+ Get the full response text given a specific encoding.
89
+ """
90
+ ...
91
+
92
+ def json(self) -> Any:
93
+ r"""
94
+ Get the JSON content of the response.
95
+ """
96
+
97
+ def bytes(self) -> bytes:
98
+ r"""
99
+ Get the bytes content of the response.
100
+ """
101
+ ...
102
+
103
+ def stream(self) -> Streamer:
104
+ r"""
105
+ Get the response into a `Stream` of `Bytes` from the body.
106
+ """
107
+ ...
108
+
109
+ def close(self) -> None:
110
+ r"""
111
+ Close the response connection.
112
+ """
113
+
114
+ def __enter__(self) -> "Response": ...
115
+ def __exit__(self, _exc_type: Any, _exc_value: Any, _traceback: Any) -> None: ...
116
+
117
+
118
+ class WebSocket:
119
+ r"""
120
+ A blocking WebSocket response.
121
+ """
122
+
123
+ status: StatusCode
124
+ r"""
125
+ Get the status code of the response.
126
+ """
127
+
128
+ version: Version
129
+ r"""
130
+ Get the HTTP version of the response.
131
+ """
132
+
133
+ headers: HeaderMap
134
+ r"""
135
+ Get the headers of the response.
136
+ """
137
+
138
+ cookies: List[Cookie]
139
+ r"""
140
+ Get the cookies of the response.
141
+ """
142
+
143
+ remote_addr: Optional[SocketAddr]
144
+ r"""
145
+ Get the remote address of the response.
146
+ """
147
+
148
+ protocol: Optional[str]
149
+ r"""
150
+ Get the WebSocket protocol.
151
+ """
152
+
153
+ def recv(self, timeout: datetime.timedelta | None = None) -> Optional[Message]:
154
+ r"""
155
+ Receive a message from the WebSocket.
156
+ """
157
+
158
+ def send(self, message: Message) -> None:
159
+ r"""
160
+ Send a message to the WebSocket.
161
+
162
+ # Arguments
163
+
164
+ * `message` - The message to send.
165
+ """
166
+
167
+ def send_all(self, messages: List[Message]) -> None:
168
+ r"""
169
+ Send multiple messages to the WebSocket.
170
+
171
+ # Arguments
172
+
173
+ * `messages` - The list of messages to send.
174
+ """
175
+
176
+ def close(
177
+ self,
178
+ code: int | None = None,
179
+ reason: str | None = None,
180
+ ) -> None:
181
+ r"""
182
+ Close the WebSocket connection.
183
+
184
+ # Arguments
185
+
186
+ * `code` - An optional close code.
187
+ * `reason` - An optional reason for closing.
188
+ """
189
+
190
+ def __enter__(self) -> "WebSocket": ...
191
+ def __exit__(self, _exc_type: Any, _exc_value: Any, _traceback: Any) -> None: ...
192
+
193
+
15
194
  class Client:
16
195
  r"""
17
196
  A blocking client for making HTTP requests.
18
197
  """
19
198
 
20
199
  def __init__(
21
- cls,
200
+ self,
22
201
  **kwargs: Unpack[ClientParams],
23
- ) -> "Client":
202
+ ) -> None:
24
203
  r"""
25
204
  Creates a new blocking Client instance.
26
205
 
27
- Args:
28
- emulation: Browser fingerprint/Emulation config.
29
- user_agent: Default User-Agent string.
30
- headers: Default request headers.
31
- orig_headers: Original request headers (case-sensitive and order).
32
- referer: Automatically set Referer.
33
- allow_redirects: Allow automatic redirects.
34
- max_redirects: Maximum number of redirects.
35
- cookie_store: Enable cookie store.
36
- lookup_ip_strategy: IP lookup strategy.
37
- timeout: Total timeout (seconds).
38
- connect_timeout: Connection timeout (seconds).
39
- read_timeout: Read timeout (seconds).
40
- tcp_keepalive: TCP keepalive time (seconds).
41
- tcp_keepalive_interval: TCP keepalive interval (seconds).
42
- tcp_keepalive_retries: TCP keepalive retry count.
43
- tcp_user_timeout: TCP user timeout (seconds).
44
- tcp_nodelay: Enable TCP_NODELAY.
45
- tcp_reuse_address: Enable SO_REUSEADDR.
46
- pool_idle_timeout: Connection pool idle timeout (seconds).
47
- pool_max_idle_per_host: Max idle connections per host.
48
- pool_max_size: Max total connections in pool.
49
- http1_only: Enable HTTP/1.1 only.
50
- http2_only: Enable HTTP/2 only.
51
- https_only: Enable HTTPS only.
52
- http2_max_retry_count: Max HTTP/2 retry count.
53
- verify: Verify SSL or specify CA path.
54
- identity: Represents a private key and X509 cert as a client certificate.
55
- keylog: Key logging policy (environment or file).
56
- tls_info: Return TLS info.
57
- min_tls_version: Minimum TLS version.
58
- max_tls_version: Maximum TLS version.
59
- no_proxy: Disable proxy.
60
- proxies: Proxy server list.
61
- local_address: Local bind address.
62
- interface: Local network interface.
63
- gzip: Enable gzip decompression.
64
- brotli: Enable brotli decompression.
65
- deflate: Enable deflate decompression.
66
- zstd: Enable zstd decompression.
67
-
68
206
  # Examples
69
207
 
70
208
  ```python
@@ -72,13 +210,14 @@ class Client:
72
210
  import rnet
73
211
 
74
212
  client = rnet.blocking.Client(
75
- user_agent="my-app/0.0.1",
213
+ user_agent="Mozilla/5.0",
76
214
  timeout=10,
77
215
  )
78
216
  response = client.get('https://httpbin.org/get')
79
217
  print(response.text())
80
218
  ```
81
219
  """
220
+ ...
82
221
 
83
222
  def request(
84
223
  self,
@@ -93,17 +232,13 @@ class Client:
93
232
 
94
233
  ```python
95
234
  import rnet
96
- import asyncio
97
235
  from rnet import Method
98
236
 
99
- async def main():
100
- client = rnet.blocking.Client()
101
- response = client.request(Method.GET, "https://httpbin.org/anything")
102
- print(response.text())
103
-
104
- asyncio.run(main())
237
+ client = rnet.blocking.Client()
238
+ response = client.request(Method.GET, "https://httpbin.org/anything")
105
239
  ```
106
240
  """
241
+ ...
107
242
 
108
243
  def websocket(self, url: str, **kwargs: Unpack[WebSocketRequest]) -> "WebSocket":
109
244
  r"""
@@ -113,19 +248,16 @@ class Client:
113
248
 
114
249
  ```python
115
250
  import rnet
116
- import asyncio
117
251
 
118
- async def main():
119
- client = rnet.blocking.Client()
120
- ws = client.websocket("wss://echo.websocket.org")
121
- ws.send(rnet.Message.from_text("Hello, WebSocket!"))
122
- message = ws.recv()
123
- print("Received:", message.data)
124
- ws.close()
125
-
126
- asyncio.run(main())
252
+ client = rnet.blocking.Client()
253
+ ws = client.websocket("wss://echo.websocket.org")
254
+ ws.send(rnet.Message.from_text("Hello, WebSocket!"))
255
+ message = ws.recv()
256
+ print("Received:", message.data)
257
+ ws.close()
127
258
  ```
128
259
  """
260
+ ...
129
261
 
130
262
  def trace(
131
263
  self,
@@ -139,17 +271,14 @@ class Client:
139
271
 
140
272
  ```python
141
273
  import rnet
142
- import asyncio
143
274
  from rnet import Method
144
275
 
145
- async def main():
146
- client = rnet.blocking.Client()
147
- response = client.trace("https://httpbin.org/anything")
148
- print(response.text())
149
-
150
- asyncio.run(main())
276
+ client = rnet.blocking.Client()
277
+ response = client.trace("https://httpbin.org/anything")
278
+ print(response.text())
151
279
  ```
152
280
  """
281
+ ...
153
282
 
154
283
  def options(
155
284
  self,
@@ -163,17 +292,14 @@ class Client:
163
292
 
164
293
  ```python
165
294
  import rnet
166
- import asyncio
167
295
  from rnet import Method
168
296
 
169
- async def main():
170
- client = rnet.blocking.Client()
171
- response = client.options("https://httpbin.org/anything")
172
- print(response.text())
173
-
174
- asyncio.run(main())
297
+ client = rnet.blocking.Client()
298
+ response = client.options("https://httpbin.org/anything")
299
+ print(response.text())
175
300
  ```
176
301
  """
302
+ ...
177
303
 
178
304
  def head(
179
305
  self,
@@ -187,17 +313,15 @@ class Client:
187
313
 
188
314
  ```python
189
315
  import rnet
190
- import asyncio
191
316
  from rnet import Method
192
317
 
193
- async def main():
194
- client = rnet.blocking.Client()
195
- response = client.head("https://httpbin.org/anything")
196
- print(response.text())
197
-
198
- asyncio.run(main())
318
+ def main():
319
+ client = rnet.blocking.Client()
320
+ response = client.head("https://httpbin.org/anything")
321
+ print(response.text())
199
322
  ```
200
323
  """
324
+ ...
201
325
 
202
326
  def delete(
203
327
  self,
@@ -211,17 +335,14 @@ class Client:
211
335
 
212
336
  ```python
213
337
  import rnet
214
- import asyncio
215
338
  from rnet import Method
216
339
 
217
- async def main():
218
- client = rnet.blocking.Client()
219
- response = client.delete("https://httpbin.org/anything")
220
- print(response.text())
221
-
222
- asyncio.run(main())
340
+ client = rnet.blocking.Client()
341
+ response = client.delete("https://httpbin.org/anything")
342
+ print(response.text())
223
343
  ```
224
344
  """
345
+ ...
225
346
 
226
347
  def patch(
227
348
  self,
@@ -235,17 +356,14 @@ class Client:
235
356
 
236
357
  ```python
237
358
  import rnet
238
- import asyncio
239
359
  from rnet import Method
240
360
 
241
- async def main():
242
- client = rnet.blocking.Client()
243
- response = client.patch("https://httpbin.org/anything", json={"key": "value"})
244
- print(response.text())
245
-
246
- asyncio.run(main())
361
+ client = rnet.blocking.Client()
362
+ response = client.patch("https://httpbin.org/anything", json={"key": "value"})
363
+ print(response.text())
247
364
  ```
248
365
  """
366
+ ...
249
367
 
250
368
  def put(
251
369
  self,
@@ -259,17 +377,14 @@ class Client:
259
377
 
260
378
  ```python
261
379
  import rnet
262
- import asyncio
263
380
  from rnet import Method
264
381
 
265
- async def main():
266
- client = rnet.blocking.Client()
267
- response = client.put("https://httpbin.org/anything", json={"key": "value"})
268
- print(response.text())
269
-
270
- asyncio.run(main())
382
+ client = rnet.blocking.Client()
383
+ response = client.put("https://httpbin.org/anything", json={"key": "value"})
384
+ print(response.text())
271
385
  ```
272
386
  """
387
+ ...
273
388
 
274
389
  def post(
275
390
  self,
@@ -283,17 +398,14 @@ class Client:
283
398
 
284
399
  ```python
285
400
  import rnet
286
- import asyncio
287
401
  from rnet import Method
288
402
 
289
- async def main():
290
- client = rnet.blocking.Client()
291
- response = client.post("https://httpbin.org/anything", json={"key": "value"})
292
- print(response.text())
293
-
294
- asyncio.run(main())
403
+ client = rnet.blocking.Client()
404
+ response = client.post("https://httpbin.org/anything", json={"key": "value"})
405
+ print(response.text())
295
406
  ```
296
407
  """
408
+ ...
297
409
 
298
410
  def get(
299
411
  self,
@@ -307,169 +419,11 @@ class Client:
307
419
 
308
420
  ```python
309
421
  import rnet
310
- import asyncio
311
422
  from rnet import Method
312
423
 
313
- async def main():
314
- client = rnet.blocking.Client()
315
- response = client.get("https://httpbin.org/anything")
316
- print(response.text())
317
-
318
- asyncio.run(main())
424
+ client = rnet.blocking.Client()
425
+ response = client.get("https://httpbin.org/anything")
426
+ print(response.text())
319
427
  ```
320
428
  """
321
-
322
-
323
- class Response:
324
- r"""
325
- A blocking response from a request.
326
- """
327
-
328
- url: str
329
- r"""
330
- Get the URL of the response.
331
- """
332
-
333
- status: StatusCode
334
- r"""
335
- Get the status code of the response.
336
- """
337
-
338
- version: Version
339
- r"""
340
- Get the HTTP version of the response.
341
- """
342
-
343
- headers: HeaderMap
344
- r"""
345
- Get the headers of the response.
346
- """
347
-
348
- cookies: List[Cookie]
349
- r"""
350
- Get the cookies of the response.
351
- """
352
-
353
- content_length: int
354
- r"""
355
- Get the content length of the response.
356
- """
357
-
358
- remote_addr: Optional[SocketAddr]
359
- r"""
360
- Get the remote address of the response.
361
- """
362
-
363
- local_addr: Optional[SocketAddr]
364
- r"""
365
- Get the local address of the response.
366
- """
367
-
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
- """
377
-
378
- def text(self) -> str:
379
- r"""
380
- Get the text content of the response.
381
- """
382
-
383
- def text_with_charset(self, encoding: str) -> str:
384
- r"""
385
- Get the text content of the response with a specific charset.
386
-
387
- # Arguments
388
-
389
- * `encoding` - The default encoding to use if the charset is not specified.
390
- """
391
-
392
- def json(self) -> Any:
393
- r"""
394
- Get the JSON content of the response.
395
- """
396
-
397
- def bytes(self) -> bytes:
398
- r"""
399
- Get the bytes content of the response.
400
- """
401
-
402
- def stream(self) -> Streamer:
403
- r"""
404
- Get the response into a `Stream` of `Bytes` from the body.
405
- """
406
-
407
- def close(self) -> None:
408
- r"""
409
- Close the response connection.
410
- """
411
-
412
- def __enter__(self) -> "Response": ...
413
- def __exit__(self, _exc_type: Any, _exc_value: Any, _traceback: Any) -> None: ...
414
-
415
-
416
- class WebSocket:
417
- r"""
418
- A blocking WebSocket response.
419
- """
420
-
421
- status: StatusCode
422
- r"""
423
- Get the status code of the response.
424
- """
425
- version: Version
426
- r"""
427
- Get the HTTP version of the response.
428
- """
429
- headers: HeaderMap
430
- r"""
431
- Get the headers of the response.
432
- """
433
- cookies: List[Cookie]
434
- r"""
435
- Get the cookies of the response.
436
- """
437
- remote_addr: Optional[SocketAddr]
438
- r"""
439
- Get the remote address of the response.
440
- """
441
- protocol: Optional[str]
442
- r"""
443
- Get the WebSocket protocol.
444
- """
445
-
446
- def __enter__(self) -> "WebSocket": ...
447
- def __exit__(self, _exc_type: Any, _exc_value: Any, _traceback: Any) -> None: ...
448
-
449
- def recv(self, timeout: datetime.timedelta | None = None) -> Optional[Message]:
450
- r"""
451
- Receives a message from the WebSocket.
452
- """
453
-
454
- def send(self, message: Message) -> None:
455
- r"""
456
- Sends a message to the WebSocket.
457
-
458
- # Arguments
459
-
460
- * `message` - The message to send.
461
- """
462
-
463
- def close(
464
- self,
465
- code: Optional[int] = None,
466
- reason: Optional[str] = None,
467
- ) -> None:
468
- r"""
469
- Closes the WebSocket connection.
470
-
471
- # Arguments
472
-
473
- * `code` - An optional close code.
474
- * `reason` - An optional reason for closing.
475
- """
429
+ ...