rnet 3.0.0rc2__cp311-abi3-manylinux_2_34_armv7l.whl → 3.0.0rc4__cp311-abi3-manylinux_2_34_armv7l.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__.py +1 -3
- rnet/__init__.pyi +806 -596
- rnet/blocking.py +218 -266
- rnet/cookie.py +16 -6
- rnet/emulation.py +6 -3
- rnet/exceptions.py +17 -13
- rnet/header.py +50 -127
- rnet/rnet.abi3.so +0 -0
- rnet/tls.py +6 -4
- {rnet-3.0.0rc2.dist-info → rnet-3.0.0rc4.dist-info}/METADATA +47 -47
- rnet-3.0.0rc4.dist-info/RECORD +14 -0
- rnet-3.0.0rc4.dist-info/licenses/LICENSE +201 -0
- rnet-3.0.0rc2.dist-info/RECORD +0 -14
- rnet-3.0.0rc2.dist-info/licenses/LICENSE +0 -674
- {rnet-3.0.0rc2.dist-info → rnet-3.0.0rc4.dist-info}/WHEEL +0 -0
rnet/blocking.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
from rnet import ClientParams, Message, Request, Streamer, WebSocketRequest
|
|
1
|
+
import datetime
|
|
2
|
+
from rnet import ClientParams, History, Message, Request, Streamer, WebSocketRequest
|
|
3
3
|
from typing import (
|
|
4
4
|
Optional,
|
|
5
5
|
Any,
|
|
@@ -12,59 +12,187 @@ from rnet.header import HeaderMap
|
|
|
12
12
|
from rnet.cookie import Cookie
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
class Response:
|
|
16
|
+
r"""
|
|
17
|
+
A blocking response from a request.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
url: str
|
|
21
|
+
r"""
|
|
22
|
+
Get the URL of the response.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
status: StatusCode
|
|
26
|
+
r"""
|
|
27
|
+
Get the status code of the response.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
version: Version
|
|
31
|
+
r"""
|
|
32
|
+
Get the HTTP version of the response.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
headers: HeaderMap
|
|
36
|
+
r"""
|
|
37
|
+
Get the headers of the response.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
cookies: List[Cookie]
|
|
41
|
+
r"""
|
|
42
|
+
Get the cookies of the response.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
content_length: Optional[int]
|
|
46
|
+
r"""
|
|
47
|
+
Get the content length of the response.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
remote_addr: Optional[SocketAddr]
|
|
51
|
+
r"""
|
|
52
|
+
Get the remote address of the response.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
local_addr: Optional[SocketAddr]
|
|
56
|
+
r"""
|
|
57
|
+
Get the local address of the response.
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
history: List[History]
|
|
61
|
+
r"""
|
|
62
|
+
Get the redirect history of the Response.
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
peer_certificate: Optional[bytes]
|
|
66
|
+
r"""
|
|
67
|
+
Get the DER encoded leaf certificate of the response.
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
def text(self) -> str:
|
|
71
|
+
r"""
|
|
72
|
+
Get the text content of the response.
|
|
73
|
+
"""
|
|
74
|
+
...
|
|
75
|
+
|
|
76
|
+
def text_with_charset(self, encoding: str) -> str:
|
|
77
|
+
r"""
|
|
78
|
+
Get the full response text given a specific encoding.
|
|
79
|
+
"""
|
|
80
|
+
...
|
|
81
|
+
|
|
82
|
+
def json(self) -> Any:
|
|
83
|
+
r"""
|
|
84
|
+
Get the JSON content of the response.
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
def bytes(self) -> bytes:
|
|
88
|
+
r"""
|
|
89
|
+
Get the bytes content of the response.
|
|
90
|
+
"""
|
|
91
|
+
...
|
|
92
|
+
|
|
93
|
+
def stream(self) -> Streamer:
|
|
94
|
+
r"""
|
|
95
|
+
Get the response into a `Stream` of `Bytes` from the body.
|
|
96
|
+
"""
|
|
97
|
+
...
|
|
98
|
+
|
|
99
|
+
def close(self) -> None:
|
|
100
|
+
r"""
|
|
101
|
+
Close the response connection.
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
def __enter__(self) -> "Response": ...
|
|
105
|
+
def __exit__(self, _exc_type: Any, _exc_value: Any, _traceback: Any) -> None: ...
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class WebSocket:
|
|
109
|
+
r"""
|
|
110
|
+
A blocking WebSocket response.
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
status: StatusCode
|
|
114
|
+
r"""
|
|
115
|
+
Get the status code of the response.
|
|
116
|
+
"""
|
|
117
|
+
|
|
118
|
+
version: Version
|
|
119
|
+
r"""
|
|
120
|
+
Get the HTTP version of the response.
|
|
121
|
+
"""
|
|
122
|
+
|
|
123
|
+
headers: HeaderMap
|
|
124
|
+
r"""
|
|
125
|
+
Get the headers of the response.
|
|
126
|
+
"""
|
|
127
|
+
|
|
128
|
+
cookies: List[Cookie]
|
|
129
|
+
r"""
|
|
130
|
+
Get the cookies of the response.
|
|
131
|
+
"""
|
|
132
|
+
|
|
133
|
+
remote_addr: Optional[SocketAddr]
|
|
134
|
+
r"""
|
|
135
|
+
Get the remote address of the response.
|
|
136
|
+
"""
|
|
137
|
+
|
|
138
|
+
protocol: Optional[str]
|
|
139
|
+
r"""
|
|
140
|
+
Get the WebSocket protocol.
|
|
141
|
+
"""
|
|
142
|
+
|
|
143
|
+
def recv(self, timeout: datetime.timedelta | None = None) -> Optional[Message]:
|
|
144
|
+
r"""
|
|
145
|
+
Receive a message from the WebSocket.
|
|
146
|
+
"""
|
|
147
|
+
|
|
148
|
+
def send(self, message: Message) -> None:
|
|
149
|
+
r"""
|
|
150
|
+
Send a message to the WebSocket.
|
|
151
|
+
|
|
152
|
+
# Arguments
|
|
153
|
+
|
|
154
|
+
* `message` - The message to send.
|
|
155
|
+
"""
|
|
156
|
+
|
|
157
|
+
def send_all(self, messages: List[Message]) -> None:
|
|
158
|
+
r"""
|
|
159
|
+
Send multiple messages to the WebSocket.
|
|
160
|
+
|
|
161
|
+
# Arguments
|
|
162
|
+
|
|
163
|
+
* `messages` - The list of messages to send.
|
|
164
|
+
"""
|
|
165
|
+
|
|
166
|
+
def close(
|
|
167
|
+
self,
|
|
168
|
+
code: int | None = None,
|
|
169
|
+
reason: str | None = None,
|
|
170
|
+
) -> None:
|
|
171
|
+
r"""
|
|
172
|
+
Close the WebSocket connection.
|
|
173
|
+
|
|
174
|
+
# Arguments
|
|
175
|
+
|
|
176
|
+
* `code` - An optional close code.
|
|
177
|
+
* `reason` - An optional reason for closing.
|
|
178
|
+
"""
|
|
179
|
+
|
|
180
|
+
def __enter__(self) -> "WebSocket": ...
|
|
181
|
+
def __exit__(self, _exc_type: Any, _exc_value: Any, _traceback: Any) -> None: ...
|
|
182
|
+
|
|
183
|
+
|
|
15
184
|
class Client:
|
|
16
185
|
r"""
|
|
17
186
|
A blocking client for making HTTP requests.
|
|
18
187
|
"""
|
|
19
188
|
|
|
20
189
|
def __init__(
|
|
21
|
-
|
|
190
|
+
self,
|
|
22
191
|
**kwargs: Unpack[ClientParams],
|
|
23
|
-
) ->
|
|
192
|
+
) -> None:
|
|
24
193
|
r"""
|
|
25
194
|
Creates a new blocking Client instance.
|
|
26
195
|
|
|
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
196
|
# Examples
|
|
69
197
|
|
|
70
198
|
```python
|
|
@@ -72,13 +200,14 @@ class Client:
|
|
|
72
200
|
import rnet
|
|
73
201
|
|
|
74
202
|
client = rnet.blocking.Client(
|
|
75
|
-
user_agent="
|
|
203
|
+
user_agent="Mozilla/5.0",
|
|
76
204
|
timeout=10,
|
|
77
205
|
)
|
|
78
206
|
response = client.get('https://httpbin.org/get')
|
|
79
207
|
print(response.text())
|
|
80
208
|
```
|
|
81
209
|
"""
|
|
210
|
+
...
|
|
82
211
|
|
|
83
212
|
def request(
|
|
84
213
|
self,
|
|
@@ -93,17 +222,13 @@ class Client:
|
|
|
93
222
|
|
|
94
223
|
```python
|
|
95
224
|
import rnet
|
|
96
|
-
import asyncio
|
|
97
225
|
from rnet import Method
|
|
98
226
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
response = client.request(Method.GET, "https://httpbin.org/anything")
|
|
102
|
-
print(response.text())
|
|
103
|
-
|
|
104
|
-
asyncio.run(main())
|
|
227
|
+
client = rnet.blocking.Client()
|
|
228
|
+
response = client.request(Method.GET, "https://httpbin.org/anything")
|
|
105
229
|
```
|
|
106
230
|
"""
|
|
231
|
+
...
|
|
107
232
|
|
|
108
233
|
def websocket(self, url: str, **kwargs: Unpack[WebSocketRequest]) -> "WebSocket":
|
|
109
234
|
r"""
|
|
@@ -113,19 +238,16 @@ class Client:
|
|
|
113
238
|
|
|
114
239
|
```python
|
|
115
240
|
import rnet
|
|
116
|
-
import asyncio
|
|
117
|
-
|
|
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
241
|
|
|
126
|
-
|
|
242
|
+
client = rnet.blocking.Client()
|
|
243
|
+
ws = client.websocket("wss://echo.websocket.org")
|
|
244
|
+
ws.send(rnet.Message.from_text("Hello, WebSocket!"))
|
|
245
|
+
message = ws.recv()
|
|
246
|
+
print("Received:", message.data)
|
|
247
|
+
ws.close()
|
|
127
248
|
```
|
|
128
249
|
"""
|
|
250
|
+
...
|
|
129
251
|
|
|
130
252
|
def trace(
|
|
131
253
|
self,
|
|
@@ -139,17 +261,14 @@ class Client:
|
|
|
139
261
|
|
|
140
262
|
```python
|
|
141
263
|
import rnet
|
|
142
|
-
import asyncio
|
|
143
264
|
from rnet import Method
|
|
144
265
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
print(response.text())
|
|
149
|
-
|
|
150
|
-
asyncio.run(main())
|
|
266
|
+
client = rnet.blocking.Client()
|
|
267
|
+
response = client.trace("https://httpbin.org/anything")
|
|
268
|
+
print(response.text())
|
|
151
269
|
```
|
|
152
270
|
"""
|
|
271
|
+
...
|
|
153
272
|
|
|
154
273
|
def options(
|
|
155
274
|
self,
|
|
@@ -163,17 +282,14 @@ class Client:
|
|
|
163
282
|
|
|
164
283
|
```python
|
|
165
284
|
import rnet
|
|
166
|
-
import asyncio
|
|
167
285
|
from rnet import Method
|
|
168
286
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
print(response.text())
|
|
173
|
-
|
|
174
|
-
asyncio.run(main())
|
|
287
|
+
client = rnet.blocking.Client()
|
|
288
|
+
response = client.options("https://httpbin.org/anything")
|
|
289
|
+
print(response.text())
|
|
175
290
|
```
|
|
176
291
|
"""
|
|
292
|
+
...
|
|
177
293
|
|
|
178
294
|
def head(
|
|
179
295
|
self,
|
|
@@ -187,17 +303,15 @@ class Client:
|
|
|
187
303
|
|
|
188
304
|
```python
|
|
189
305
|
import rnet
|
|
190
|
-
import asyncio
|
|
191
306
|
from rnet import Method
|
|
192
307
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
asyncio.run(main())
|
|
308
|
+
def main():
|
|
309
|
+
client = rnet.blocking.Client()
|
|
310
|
+
response = client.head("https://httpbin.org/anything")
|
|
311
|
+
print(response.text())
|
|
199
312
|
```
|
|
200
313
|
"""
|
|
314
|
+
...
|
|
201
315
|
|
|
202
316
|
def delete(
|
|
203
317
|
self,
|
|
@@ -211,17 +325,14 @@ class Client:
|
|
|
211
325
|
|
|
212
326
|
```python
|
|
213
327
|
import rnet
|
|
214
|
-
import asyncio
|
|
215
328
|
from rnet import Method
|
|
216
329
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
print(response.text())
|
|
221
|
-
|
|
222
|
-
asyncio.run(main())
|
|
330
|
+
client = rnet.blocking.Client()
|
|
331
|
+
response = client.delete("https://httpbin.org/anything")
|
|
332
|
+
print(response.text())
|
|
223
333
|
```
|
|
224
334
|
"""
|
|
335
|
+
...
|
|
225
336
|
|
|
226
337
|
def patch(
|
|
227
338
|
self,
|
|
@@ -235,17 +346,14 @@ class Client:
|
|
|
235
346
|
|
|
236
347
|
```python
|
|
237
348
|
import rnet
|
|
238
|
-
import asyncio
|
|
239
349
|
from rnet import Method
|
|
240
350
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
print(response.text())
|
|
245
|
-
|
|
246
|
-
asyncio.run(main())
|
|
351
|
+
client = rnet.blocking.Client()
|
|
352
|
+
response = client.patch("https://httpbin.org/anything", json={"key": "value"})
|
|
353
|
+
print(response.text())
|
|
247
354
|
```
|
|
248
355
|
"""
|
|
356
|
+
...
|
|
249
357
|
|
|
250
358
|
def put(
|
|
251
359
|
self,
|
|
@@ -259,17 +367,14 @@ class Client:
|
|
|
259
367
|
|
|
260
368
|
```python
|
|
261
369
|
import rnet
|
|
262
|
-
import asyncio
|
|
263
370
|
from rnet import Method
|
|
264
371
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
print(response.text())
|
|
269
|
-
|
|
270
|
-
asyncio.run(main())
|
|
372
|
+
client = rnet.blocking.Client()
|
|
373
|
+
response = client.put("https://httpbin.org/anything", json={"key": "value"})
|
|
374
|
+
print(response.text())
|
|
271
375
|
```
|
|
272
376
|
"""
|
|
377
|
+
...
|
|
273
378
|
|
|
274
379
|
def post(
|
|
275
380
|
self,
|
|
@@ -283,17 +388,14 @@ class Client:
|
|
|
283
388
|
|
|
284
389
|
```python
|
|
285
390
|
import rnet
|
|
286
|
-
import asyncio
|
|
287
391
|
from rnet import Method
|
|
288
392
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
print(response.text())
|
|
293
|
-
|
|
294
|
-
asyncio.run(main())
|
|
393
|
+
client = rnet.blocking.Client()
|
|
394
|
+
response = client.post("https://httpbin.org/anything", json={"key": "value"})
|
|
395
|
+
print(response.text())
|
|
295
396
|
```
|
|
296
397
|
"""
|
|
398
|
+
...
|
|
297
399
|
|
|
298
400
|
def get(
|
|
299
401
|
self,
|
|
@@ -307,161 +409,11 @@ class Client:
|
|
|
307
409
|
|
|
308
410
|
```python
|
|
309
411
|
import rnet
|
|
310
|
-
import asyncio
|
|
311
412
|
from rnet import Method
|
|
312
413
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
print(response.text())
|
|
317
|
-
|
|
318
|
-
asyncio.run(main())
|
|
414
|
+
client = rnet.blocking.Client()
|
|
415
|
+
response = client.get("https://httpbin.org/anything")
|
|
416
|
+
print(response.text())
|
|
319
417
|
```
|
|
320
418
|
"""
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
class Response:
|
|
324
|
-
r"""
|
|
325
|
-
A blocking response from a request.
|
|
326
|
-
"""
|
|
327
|
-
|
|
328
|
-
url: str
|
|
329
|
-
r"""
|
|
330
|
-
Returns the URL of the response.
|
|
331
|
-
"""
|
|
332
|
-
status: StatusCode
|
|
333
|
-
r"""
|
|
334
|
-
Returns the status code of the response.
|
|
335
|
-
"""
|
|
336
|
-
version: Version
|
|
337
|
-
r"""
|
|
338
|
-
Returns the HTTP version of the response.
|
|
339
|
-
"""
|
|
340
|
-
headers: HeaderMap
|
|
341
|
-
r"""
|
|
342
|
-
Returns the headers of the response.
|
|
343
|
-
"""
|
|
344
|
-
cookies: List[Cookie]
|
|
345
|
-
r"""
|
|
346
|
-
Returns the cookies of the response.
|
|
347
|
-
"""
|
|
348
|
-
content_length: int
|
|
349
|
-
r"""
|
|
350
|
-
Returns the content length of the response.
|
|
351
|
-
"""
|
|
352
|
-
remote_addr: Optional[SocketAddr]
|
|
353
|
-
r"""
|
|
354
|
-
Returns the remote address of the response.
|
|
355
|
-
"""
|
|
356
|
-
local_addr: Optional[SocketAddr]
|
|
357
|
-
r"""
|
|
358
|
-
Returns the local address of the response.
|
|
359
|
-
"""
|
|
360
|
-
encoding: str
|
|
361
|
-
r"""
|
|
362
|
-
Encoding to decode with when accessing text.
|
|
363
|
-
"""
|
|
364
|
-
|
|
365
|
-
def __enter__(self) -> "Response": ...
|
|
366
|
-
def __exit__(self, _exc_type: Any, _exc_value: Any, _traceback: Any) -> None: ...
|
|
367
|
-
def peer_certificate(self) -> Optional[bytes]:
|
|
368
|
-
r"""
|
|
369
|
-
Returns the TLS peer certificate of the response.
|
|
370
|
-
"""
|
|
371
|
-
|
|
372
|
-
def text(self) -> str:
|
|
373
|
-
r"""
|
|
374
|
-
Returns the text content of the response.
|
|
375
|
-
"""
|
|
376
|
-
|
|
377
|
-
def text_with_charset(self, encoding: str) -> str:
|
|
378
|
-
r"""
|
|
379
|
-
Returns the text content of the response with a specific charset.
|
|
380
|
-
|
|
381
|
-
# Arguments
|
|
382
|
-
|
|
383
|
-
* `encoding` - The default encoding to use if the charset is not specified.
|
|
384
|
-
"""
|
|
385
|
-
|
|
386
|
-
def json(self) -> Any:
|
|
387
|
-
r"""
|
|
388
|
-
Returns the JSON content of the response.
|
|
389
|
-
"""
|
|
390
|
-
|
|
391
|
-
def bytes(self) -> bytes:
|
|
392
|
-
r"""
|
|
393
|
-
Returns the bytes content of the response.
|
|
394
|
-
"""
|
|
395
|
-
|
|
396
|
-
def stream(self) -> Streamer:
|
|
397
|
-
r"""
|
|
398
|
-
Convert the response into a `Stream` of `Bytes` from the body.
|
|
399
|
-
"""
|
|
400
|
-
|
|
401
|
-
def close(self) -> None:
|
|
402
|
-
r"""
|
|
403
|
-
Closes the response connection.
|
|
404
|
-
"""
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
class WebSocket:
|
|
408
|
-
r"""
|
|
409
|
-
A blocking WebSocket response.
|
|
410
|
-
"""
|
|
411
|
-
|
|
412
|
-
status: StatusCode
|
|
413
|
-
r"""
|
|
414
|
-
Returns the status code of the response.
|
|
415
|
-
"""
|
|
416
|
-
version: Version
|
|
417
|
-
r"""
|
|
418
|
-
Returns the HTTP version of the response.
|
|
419
|
-
"""
|
|
420
|
-
headers: HeaderMap
|
|
421
|
-
r"""
|
|
422
|
-
Returns the headers of the response.
|
|
423
|
-
"""
|
|
424
|
-
cookies: List[Cookie]
|
|
425
|
-
r"""
|
|
426
|
-
Returns the cookies of the response.
|
|
427
|
-
"""
|
|
428
|
-
remote_addr: Optional[SocketAddr]
|
|
429
|
-
r"""
|
|
430
|
-
Returns the remote address of the response.
|
|
431
|
-
"""
|
|
432
|
-
protocol: Optional[str]
|
|
433
|
-
r"""
|
|
434
|
-
Returns the WebSocket protocol.
|
|
435
|
-
"""
|
|
436
|
-
|
|
437
|
-
def __iter__(self) -> "WebSocket": ...
|
|
438
|
-
def __next__(self) -> Message: ...
|
|
439
|
-
def __enter__(self) -> "WebSocket": ...
|
|
440
|
-
def __exit__(self, _exc_type: Any, _exc_value: Any, _traceback: Any) -> None: ...
|
|
441
|
-
def recv(self) -> Optional[Message]:
|
|
442
|
-
r"""
|
|
443
|
-
Receives a message from the WebSocket.
|
|
444
|
-
"""
|
|
445
|
-
|
|
446
|
-
def send(self, message: Message) -> None:
|
|
447
|
-
r"""
|
|
448
|
-
Sends a message to the WebSocket.
|
|
449
|
-
|
|
450
|
-
# Arguments
|
|
451
|
-
|
|
452
|
-
* `message` - The message to send.
|
|
453
|
-
"""
|
|
454
|
-
|
|
455
|
-
def close(
|
|
456
|
-
self,
|
|
457
|
-
code: Optional[int] = None,
|
|
458
|
-
reason: Optional[str] = None,
|
|
459
|
-
) -> None:
|
|
460
|
-
r"""
|
|
461
|
-
Closes the WebSocket connection.
|
|
462
|
-
|
|
463
|
-
# Arguments
|
|
464
|
-
|
|
465
|
-
* `code` - An optional close code.
|
|
466
|
-
* `reason` - An optional reason for closing.
|
|
467
|
-
"""
|
|
419
|
+
...
|
rnet/cookie.py
CHANGED
|
@@ -10,6 +10,8 @@ import datetime
|
|
|
10
10
|
from enum import Enum, auto
|
|
11
11
|
from typing import List, Optional
|
|
12
12
|
|
|
13
|
+
__all__ = ["SameSite", "Cookie", "Jar"]
|
|
14
|
+
|
|
13
15
|
|
|
14
16
|
class SameSite(Enum):
|
|
15
17
|
r"""
|
|
@@ -68,20 +70,21 @@ class Cookie:
|
|
|
68
70
|
"""
|
|
69
71
|
|
|
70
72
|
def __init__(
|
|
71
|
-
|
|
73
|
+
self,
|
|
72
74
|
name: str,
|
|
73
75
|
value: str,
|
|
74
76
|
domain: str | None = None,
|
|
75
77
|
path: str | None = None,
|
|
76
78
|
max_age: datetime.timedelta | None = None,
|
|
77
79
|
expires: datetime.datetime | None = None,
|
|
78
|
-
http_only: bool =
|
|
79
|
-
secure: bool =
|
|
80
|
+
http_only: bool | None = None,
|
|
81
|
+
secure: bool | None = None,
|
|
80
82
|
same_site: SameSite | None = None,
|
|
81
|
-
) ->
|
|
83
|
+
) -> None:
|
|
82
84
|
r"""
|
|
83
85
|
Create a new cookie.
|
|
84
86
|
"""
|
|
87
|
+
...
|
|
85
88
|
|
|
86
89
|
def __str__(self) -> str: ...
|
|
87
90
|
|
|
@@ -94,37 +97,44 @@ class Jar:
|
|
|
94
97
|
to automatically handle cookies during HTTP requests and responses.
|
|
95
98
|
"""
|
|
96
99
|
|
|
97
|
-
def __init__(
|
|
100
|
+
def __init__(self) -> None:
|
|
98
101
|
r"""
|
|
99
102
|
Create a new cookie jar.
|
|
100
103
|
"""
|
|
104
|
+
...
|
|
101
105
|
|
|
102
106
|
def get(self, name: str, url: str) -> Optional[Cookie]:
|
|
103
107
|
r"""
|
|
104
108
|
Get a cookie by name and URL.
|
|
105
109
|
"""
|
|
110
|
+
...
|
|
106
111
|
|
|
107
112
|
def get_all(self) -> List[Cookie]:
|
|
108
113
|
r"""
|
|
109
114
|
Get all cookies.
|
|
110
115
|
"""
|
|
116
|
+
...
|
|
111
117
|
|
|
112
|
-
def
|
|
118
|
+
def add_cookie(self, cookie: Cookie, url: str) -> None:
|
|
113
119
|
r"""
|
|
114
120
|
Add a cookie to this jar.
|
|
115
121
|
"""
|
|
122
|
+
...
|
|
116
123
|
|
|
117
124
|
def add_cookie_str(self, cookie: str, url: str) -> None:
|
|
118
125
|
r"""
|
|
119
126
|
Add a cookie str to this jar.
|
|
120
127
|
"""
|
|
128
|
+
...
|
|
121
129
|
|
|
122
130
|
def remove(self, name: str, url: str) -> None:
|
|
123
131
|
r"""
|
|
124
132
|
Remove a cookie from this jar by name and URL.
|
|
125
133
|
"""
|
|
134
|
+
...
|
|
126
135
|
|
|
127
136
|
def clear(self) -> None:
|
|
128
137
|
r"""
|
|
129
138
|
Clear all cookies in this jar.
|
|
130
139
|
"""
|
|
140
|
+
...
|