rusty-req 0.1.1__tar.gz → 0.1.2__tar.gz
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 rusty-req might be problematic. Click here for more details.
- {rusty_req-0.1.1 → rusty_req-0.1.2}/Cargo.lock +40 -27
- {rusty_req-0.1.1 → rusty_req-0.1.2}/Cargo.toml +2 -2
- rusty_req-0.1.2/PKG-INFO +125 -0
- rusty_req-0.1.2/README.md +110 -0
- {rusty_req-0.1.1 → rusty_req-0.1.2}/pyproject.toml +1 -1
- {rusty_req-0.1.1 → rusty_req-0.1.2}/src/lib.rs +33 -1
- rusty_req-0.1.1/PKG-INFO +0 -17
- rusty_req-0.1.1/README.md +0 -2
- {rusty_req-0.1.1 → rusty_req-0.1.2}/.gitignore +0 -0
- {rusty_req-0.1.1 → rusty_req-0.1.2}/.idea/.gitignore +0 -0
- {rusty_req-0.1.1 → rusty_req-0.1.2}/.idea/modules.xml +0 -0
- {rusty_req-0.1.1 → rusty_req-0.1.2}/.idea/py_req_ext.iml +0 -0
- {rusty_req-0.1.1 → rusty_req-0.1.2}/.idea/vcs.xml +0 -0
|
@@ -85,9 +85,9 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
|
|
|
85
85
|
|
|
86
86
|
[[package]]
|
|
87
87
|
name = "cc"
|
|
88
|
-
version = "1.2.
|
|
88
|
+
version = "1.2.30"
|
|
89
89
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
90
|
-
checksum = "
|
|
90
|
+
checksum = "deec109607ca693028562ed836a5f1c4b8bd77755c4e132fc5ce11b0b6211ae7"
|
|
91
91
|
dependencies = [
|
|
92
92
|
"shlex",
|
|
93
93
|
]
|
|
@@ -309,9 +309,9 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
|
|
309
309
|
|
|
310
310
|
[[package]]
|
|
311
311
|
name = "h2"
|
|
312
|
-
version = "0.3.
|
|
312
|
+
version = "0.3.27"
|
|
313
313
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
314
|
-
checksum = "
|
|
314
|
+
checksum = "0beca50380b1fc32983fc1cb4587bfa4bb9e78fc259aad4a0032d2080309222d"
|
|
315
315
|
dependencies = [
|
|
316
316
|
"bytes",
|
|
317
317
|
"fnv",
|
|
@@ -556,6 +556,17 @@ version = "2.0.6"
|
|
|
556
556
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
557
557
|
checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd"
|
|
558
558
|
|
|
559
|
+
[[package]]
|
|
560
|
+
name = "io-uring"
|
|
561
|
+
version = "0.7.8"
|
|
562
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
563
|
+
checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013"
|
|
564
|
+
dependencies = [
|
|
565
|
+
"bitflags 2.9.1",
|
|
566
|
+
"cfg-if",
|
|
567
|
+
"libc",
|
|
568
|
+
]
|
|
569
|
+
|
|
559
570
|
[[package]]
|
|
560
571
|
name = "ipnet"
|
|
561
572
|
version = "2.11.0"
|
|
@@ -902,9 +913,9 @@ checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
|
|
902
913
|
|
|
903
914
|
[[package]]
|
|
904
915
|
name = "redox_syscall"
|
|
905
|
-
version = "0.5.
|
|
916
|
+
version = "0.5.15"
|
|
906
917
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
907
|
-
checksum = "
|
|
918
|
+
checksum = "7e8af0dde094006011e6a740d4879319439489813bd0bcdc7d821beaeeff48ec"
|
|
908
919
|
dependencies = [
|
|
909
920
|
"bitflags 2.9.1",
|
|
910
921
|
]
|
|
@@ -949,20 +960,6 @@ dependencies = [
|
|
|
949
960
|
"winreg",
|
|
950
961
|
]
|
|
951
962
|
|
|
952
|
-
[[package]]
|
|
953
|
-
name = "rust_http_client"
|
|
954
|
-
version = "0.1.0"
|
|
955
|
-
dependencies = [
|
|
956
|
-
"chrono",
|
|
957
|
-
"futures",
|
|
958
|
-
"once_cell",
|
|
959
|
-
"pyo3",
|
|
960
|
-
"pyo3-asyncio",
|
|
961
|
-
"reqwest",
|
|
962
|
-
"serde_json",
|
|
963
|
-
"tokio",
|
|
964
|
-
]
|
|
965
|
-
|
|
966
963
|
[[package]]
|
|
967
964
|
name = "rustc-demangle"
|
|
968
965
|
version = "0.1.25"
|
|
@@ -971,15 +968,15 @@ checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f"
|
|
|
971
968
|
|
|
972
969
|
[[package]]
|
|
973
970
|
name = "rustix"
|
|
974
|
-
version = "1.0.
|
|
971
|
+
version = "1.0.8"
|
|
975
972
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
976
|
-
checksum = "
|
|
973
|
+
checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8"
|
|
977
974
|
dependencies = [
|
|
978
975
|
"bitflags 2.9.1",
|
|
979
976
|
"errno",
|
|
980
977
|
"libc",
|
|
981
978
|
"linux-raw-sys",
|
|
982
|
-
"windows-sys 0.
|
|
979
|
+
"windows-sys 0.60.2",
|
|
983
980
|
]
|
|
984
981
|
|
|
985
982
|
[[package]]
|
|
@@ -997,6 +994,20 @@ version = "1.0.21"
|
|
|
997
994
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
998
995
|
checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d"
|
|
999
996
|
|
|
997
|
+
[[package]]
|
|
998
|
+
name = "rusty-req"
|
|
999
|
+
version = "0.1.2"
|
|
1000
|
+
dependencies = [
|
|
1001
|
+
"chrono",
|
|
1002
|
+
"futures",
|
|
1003
|
+
"once_cell",
|
|
1004
|
+
"pyo3",
|
|
1005
|
+
"pyo3-asyncio",
|
|
1006
|
+
"reqwest",
|
|
1007
|
+
"serde_json",
|
|
1008
|
+
"tokio",
|
|
1009
|
+
]
|
|
1010
|
+
|
|
1000
1011
|
[[package]]
|
|
1001
1012
|
name = "ryu"
|
|
1002
1013
|
version = "1.0.20"
|
|
@@ -1063,9 +1074,9 @@ dependencies = [
|
|
|
1063
1074
|
|
|
1064
1075
|
[[package]]
|
|
1065
1076
|
name = "serde_json"
|
|
1066
|
-
version = "1.0.
|
|
1077
|
+
version = "1.0.141"
|
|
1067
1078
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1068
|
-
checksum = "
|
|
1079
|
+
checksum = "30b9eff21ebe718216c6ec64e1d9ac57087aad11efc64e32002bce4a0d4c03d3"
|
|
1069
1080
|
dependencies = [
|
|
1070
1081
|
"itoa",
|
|
1071
1082
|
"memchr",
|
|
@@ -1208,17 +1219,19 @@ dependencies = [
|
|
|
1208
1219
|
|
|
1209
1220
|
[[package]]
|
|
1210
1221
|
name = "tokio"
|
|
1211
|
-
version = "1.
|
|
1222
|
+
version = "1.46.1"
|
|
1212
1223
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1213
|
-
checksum = "
|
|
1224
|
+
checksum = "0cc3a2344dafbe23a245241fe8b09735b521110d30fcefbbd5feb1797ca35d17"
|
|
1214
1225
|
dependencies = [
|
|
1215
1226
|
"backtrace",
|
|
1216
1227
|
"bytes",
|
|
1228
|
+
"io-uring",
|
|
1217
1229
|
"libc",
|
|
1218
1230
|
"mio",
|
|
1219
1231
|
"parking_lot",
|
|
1220
1232
|
"pin-project-lite",
|
|
1221
1233
|
"signal-hook-registry",
|
|
1234
|
+
"slab",
|
|
1222
1235
|
"socket2",
|
|
1223
1236
|
"tokio-macros",
|
|
1224
1237
|
"windows-sys 0.52.0",
|
rusty_req-0.1.2/PKG-INFO
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rusty-req
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Classifier: Programming Language :: Python
|
|
5
|
+
Classifier: Programming Language :: Python :: 3
|
|
6
|
+
Classifier: Programming Language :: Rust
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Summary: High-performance async HTTP client built with Rust for Python.
|
|
10
|
+
Author-email: kaysen <kaysen820@gmail.com>
|
|
11
|
+
License: MIT
|
|
12
|
+
Requires-Python: >=3.7
|
|
13
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
14
|
+
|
|
15
|
+
# rusty-req
|
|
16
|
+
|
|
17
|
+
基于 Rust + Python 的高性能异步请求库,适用于需要批量发送 HTTP 请求的场景。通过 Rust 实现并发请求逻辑,并通过 [maturin](https://github.com/PyO3/maturin) 封装为 Python 模块,兼具性能与易用性。
|
|
18
|
+
|
|
19
|
+
## 🔧 安装
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install rusty-req
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
或从源码构建:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
maturin build --release
|
|
29
|
+
pip install target/wheels/rusty_req-*.whl
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 🚀 功能特点
|
|
33
|
+
|
|
34
|
+
- 批量异步发送 HTTP 请求(支持 GET / POST)
|
|
35
|
+
- 支持自定义 headers / params / timeout / tag
|
|
36
|
+
- 支持全局超时时间控制(`total_timeout`)
|
|
37
|
+
- 返回响应内容、错误信息、Meta 数据
|
|
38
|
+
- 使用 Rust + Tokio 提升吞吐能力
|
|
39
|
+
|
|
40
|
+
## 📦 使用示例
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
import asyncio
|
|
44
|
+
import time
|
|
45
|
+
from rusty_req import fetch_requests, RequestItem
|
|
46
|
+
|
|
47
|
+
async def main():
|
|
48
|
+
requests = [
|
|
49
|
+
RequestItem(
|
|
50
|
+
url="https://httpbin.org/headers",
|
|
51
|
+
method="GET",
|
|
52
|
+
params=None,
|
|
53
|
+
timeout=3.0,
|
|
54
|
+
tag=f"test-get-{i}",
|
|
55
|
+
headers={
|
|
56
|
+
"Accept-Encoding": "gzip, deflate, br",
|
|
57
|
+
"Connection": "keep-alive",
|
|
58
|
+
"X-Test-Header": "ChatGPT"
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
for i in range(100)
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
start = time.perf_counter()
|
|
65
|
+
responses = await fetch_requests(requests, total_timeout=5.0)
|
|
66
|
+
duration = time.perf_counter() - start
|
|
67
|
+
|
|
68
|
+
success = sum(1 for r in responses if not r["error"])
|
|
69
|
+
failure = len(responses) - success
|
|
70
|
+
|
|
71
|
+
print(f"✅ 成功请求数: {success}")
|
|
72
|
+
print(f"❌ 失败请求数: {failure}")
|
|
73
|
+
print(f"⏱️ 总耗时: {duration:.2f} 秒")
|
|
74
|
+
|
|
75
|
+
if __name__ == "__main__":
|
|
76
|
+
asyncio.run(main())
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 🧱 数据结构说明
|
|
80
|
+
|
|
81
|
+
### `RequestItem` 参数
|
|
82
|
+
|
|
83
|
+
| 字段名 | 类型 | 必须 | 说明 |
|
|
84
|
+
|------------|------------------|------|----------------------------------------|
|
|
85
|
+
| `url` | `str` | ✅ | 请求地址 |
|
|
86
|
+
| `method` | `str` | ✅ | 请求方法(`"GET"` 或 `"POST"`) |
|
|
87
|
+
| `params` | `dict` / `None` | 否 | 查询参数(GET)或表单数据(POST) |
|
|
88
|
+
| `headers` | `dict` / `None` | 否 | 自定义请求头 |
|
|
89
|
+
| `timeout` | `float` | ✅ | 单个请求超时(秒) |
|
|
90
|
+
| `tag` | `str` | 否 | 标记请求的来源、编号等辅助信息 |
|
|
91
|
+
|
|
92
|
+
### 返回格式
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
[
|
|
96
|
+
{
|
|
97
|
+
"response": str | None, # 成功时返回内容
|
|
98
|
+
"error": str | None, # 失败时错误信息
|
|
99
|
+
"meta": {
|
|
100
|
+
"tag": str,
|
|
101
|
+
"elapsed_ms": float # 请求耗时(毫秒)
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
...
|
|
105
|
+
]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## 📑 Headers 示例
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
RequestItem(
|
|
112
|
+
url="https://httpbin.org/headers",
|
|
113
|
+
method="GET",
|
|
114
|
+
headers={
|
|
115
|
+
"User-Agent": "MyApp/1.0",
|
|
116
|
+
"X-Custom": "123"
|
|
117
|
+
},
|
|
118
|
+
timeout=5.0
|
|
119
|
+
)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## 📄 License
|
|
123
|
+
|
|
124
|
+
MIT License
|
|
125
|
+
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# rusty-req
|
|
2
|
+
|
|
3
|
+
基于 Rust + Python 的高性能异步请求库,适用于需要批量发送 HTTP 请求的场景。通过 Rust 实现并发请求逻辑,并通过 [maturin](https://github.com/PyO3/maturin) 封装为 Python 模块,兼具性能与易用性。
|
|
4
|
+
|
|
5
|
+
## 🔧 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install rusty-req
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
或从源码构建:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
maturin build --release
|
|
15
|
+
pip install target/wheels/rusty_req-*.whl
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 🚀 功能特点
|
|
19
|
+
|
|
20
|
+
- 批量异步发送 HTTP 请求(支持 GET / POST)
|
|
21
|
+
- 支持自定义 headers / params / timeout / tag
|
|
22
|
+
- 支持全局超时时间控制(`total_timeout`)
|
|
23
|
+
- 返回响应内容、错误信息、Meta 数据
|
|
24
|
+
- 使用 Rust + Tokio 提升吞吐能力
|
|
25
|
+
|
|
26
|
+
## 📦 使用示例
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
import asyncio
|
|
30
|
+
import time
|
|
31
|
+
from rusty_req import fetch_requests, RequestItem
|
|
32
|
+
|
|
33
|
+
async def main():
|
|
34
|
+
requests = [
|
|
35
|
+
RequestItem(
|
|
36
|
+
url="https://httpbin.org/headers",
|
|
37
|
+
method="GET",
|
|
38
|
+
params=None,
|
|
39
|
+
timeout=3.0,
|
|
40
|
+
tag=f"test-get-{i}",
|
|
41
|
+
headers={
|
|
42
|
+
"Accept-Encoding": "gzip, deflate, br",
|
|
43
|
+
"Connection": "keep-alive",
|
|
44
|
+
"X-Test-Header": "ChatGPT"
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
for i in range(100)
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
start = time.perf_counter()
|
|
51
|
+
responses = await fetch_requests(requests, total_timeout=5.0)
|
|
52
|
+
duration = time.perf_counter() - start
|
|
53
|
+
|
|
54
|
+
success = sum(1 for r in responses if not r["error"])
|
|
55
|
+
failure = len(responses) - success
|
|
56
|
+
|
|
57
|
+
print(f"✅ 成功请求数: {success}")
|
|
58
|
+
print(f"❌ 失败请求数: {failure}")
|
|
59
|
+
print(f"⏱️ 总耗时: {duration:.2f} 秒")
|
|
60
|
+
|
|
61
|
+
if __name__ == "__main__":
|
|
62
|
+
asyncio.run(main())
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 🧱 数据结构说明
|
|
66
|
+
|
|
67
|
+
### `RequestItem` 参数
|
|
68
|
+
|
|
69
|
+
| 字段名 | 类型 | 必须 | 说明 |
|
|
70
|
+
|------------|------------------|------|----------------------------------------|
|
|
71
|
+
| `url` | `str` | ✅ | 请求地址 |
|
|
72
|
+
| `method` | `str` | ✅ | 请求方法(`"GET"` 或 `"POST"`) |
|
|
73
|
+
| `params` | `dict` / `None` | 否 | 查询参数(GET)或表单数据(POST) |
|
|
74
|
+
| `headers` | `dict` / `None` | 否 | 自定义请求头 |
|
|
75
|
+
| `timeout` | `float` | ✅ | 单个请求超时(秒) |
|
|
76
|
+
| `tag` | `str` | 否 | 标记请求的来源、编号等辅助信息 |
|
|
77
|
+
|
|
78
|
+
### 返回格式
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
[
|
|
82
|
+
{
|
|
83
|
+
"response": str | None, # 成功时返回内容
|
|
84
|
+
"error": str | None, # 失败时错误信息
|
|
85
|
+
"meta": {
|
|
86
|
+
"tag": str,
|
|
87
|
+
"elapsed_ms": float # 请求耗时(毫秒)
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
...
|
|
91
|
+
]
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 📑 Headers 示例
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
RequestItem(
|
|
98
|
+
url="https://httpbin.org/headers",
|
|
99
|
+
method="GET",
|
|
100
|
+
headers={
|
|
101
|
+
"User-Agent": "MyApp/1.0",
|
|
102
|
+
"X-Custom": "123"
|
|
103
|
+
},
|
|
104
|
+
timeout=5.0
|
|
105
|
+
)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## 📄 License
|
|
109
|
+
|
|
110
|
+
MIT License
|
|
@@ -4,7 +4,7 @@ build-backend = "maturin"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "rusty-req"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.2"
|
|
8
8
|
description = "High-performance async HTTP client built with Rust for Python."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{ name = "kaysen", email = "kaysen820@gmail.com" }]
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#![allow(non_local_definitions)]
|
|
1
2
|
use pyo3::prelude::*;
|
|
2
3
|
use pyo3::types::{PyDict, PyList};
|
|
3
4
|
use std::collections::HashMap;
|
|
@@ -8,6 +9,7 @@ use serde_json::Value;
|
|
|
8
9
|
use chrono::{DateTime, Local};
|
|
9
10
|
use once_cell::sync::Lazy;
|
|
10
11
|
use tokio::sync::Mutex;
|
|
12
|
+
use reqwest::header::{HeaderMap, HeaderName, HeaderValue, ACCEPT_ENCODING, CONNECTION};
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
// 全局共享的HTTP客户端
|
|
@@ -31,6 +33,8 @@ pub struct RequestItem {
|
|
|
31
33
|
pub timeout: Option<f64>,
|
|
32
34
|
#[pyo3(get, set)]
|
|
33
35
|
pub tag: Option<String>, // ✅ 新增字段
|
|
36
|
+
#[pyo3(get, set)]
|
|
37
|
+
pub headers: Option<Py<PyDict>>, // ✅ 新增字段
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
#[pymethods]
|
|
@@ -42,8 +46,9 @@ impl RequestItem {
|
|
|
42
46
|
params: Option<Py<PyDict>>,
|
|
43
47
|
timeout: Option<f64>,
|
|
44
48
|
tag: Option<String>, // ✅ 新增字段
|
|
49
|
+
headers: Option<Py<PyDict>>, // ✅ 新增字段
|
|
45
50
|
) -> Self {
|
|
46
|
-
Self { url, method, params, timeout, tag }
|
|
51
|
+
Self { url, method, params, timeout, tag, headers }
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
54
|
|
|
@@ -102,6 +107,32 @@ fn fetch_requests<'py>(
|
|
|
102
107
|
&req.url
|
|
103
108
|
);
|
|
104
109
|
|
|
110
|
+
// 设置 Header
|
|
111
|
+
let mut headers = HeaderMap::new();
|
|
112
|
+
|
|
113
|
+
// 默认值
|
|
114
|
+
headers.insert(ACCEPT_ENCODING, HeaderValue::from_static("gzip, deflate, br"));
|
|
115
|
+
headers.insert(CONNECTION, HeaderValue::from_static("keep-alive"));
|
|
116
|
+
|
|
117
|
+
// 如果 Python 中传了 headers,就覆盖或追加
|
|
118
|
+
if let Some(py_headers) = &req.headers {
|
|
119
|
+
if let Ok(dict) = py_headers.as_ref(py).downcast::<PyDict>() {
|
|
120
|
+
for (k, v) in dict.iter() {
|
|
121
|
+
if let (Ok(k_str), Ok(v_str)) = (k.extract::<String>(), v.extract::<String>()) {
|
|
122
|
+
if let (Ok(h_name), Ok(h_val)) = (
|
|
123
|
+
HeaderName::from_bytes(k_str.as_bytes()),
|
|
124
|
+
HeaderValue::from_str(&v_str),
|
|
125
|
+
) {
|
|
126
|
+
headers.insert(h_name, h_val);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
builder = builder.headers(headers);
|
|
134
|
+
|
|
135
|
+
// 设置 body 参数
|
|
105
136
|
if let Some(params_dict) = &req.params {
|
|
106
137
|
if let Ok(dict) = params_dict.as_ref(py).downcast::<PyDict>() {
|
|
107
138
|
if let Ok(json_value) = py_to_json(py, dict) {
|
|
@@ -109,6 +140,7 @@ fn fetch_requests<'py>(
|
|
|
109
140
|
}
|
|
110
141
|
}
|
|
111
142
|
}
|
|
143
|
+
|
|
112
144
|
builder
|
|
113
145
|
});
|
|
114
146
|
|
rusty_req-0.1.1/PKG-INFO
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: rusty-req
|
|
3
|
-
Version: 0.1.1
|
|
4
|
-
Classifier: Programming Language :: Python
|
|
5
|
-
Classifier: Programming Language :: Python :: 3
|
|
6
|
-
Classifier: Programming Language :: Rust
|
|
7
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
-
Classifier: Operating System :: OS Independent
|
|
9
|
-
Summary: High-performance async HTTP client built with Rust for Python.
|
|
10
|
-
Author-email: kaysen <kaysen820@gmail.com>
|
|
11
|
-
License: MIT
|
|
12
|
-
Requires-Python: >=3.7
|
|
13
|
-
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
14
|
-
|
|
15
|
-
# rusty-req
|
|
16
|
-
rusty-req
|
|
17
|
-
|
rusty_req-0.1.1/README.md
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|