# reqwest
An ergonomic, batteries-included HTTP Client for Rust.
- Plain bodies, JSON, urlencoded, multipart
- Customizable redirect policy
- HTTP Proxies
- HTTPS via system-native TLS (or optionally, rustls)
- Cookie Store
- WASM
- [Changelog](CHANGELOG.md)
## Example
This asynchronous example uses [Tokio](https://tokio.rs) and enables some
optional features, so your `Cargo.toml` could look like this:
```toml
[dependencies]
reqwest = { version = "0.11", features = ["json"] }
tokio = { version = "1", features = ["full"] }
```
And then the code:
```rust,no_run
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::get("https://httpbin.org/ip")
.await?
.json::<HashMap<String, String>>()
.await?;
println!("{resp:#?}");
Ok(())
}
```
## Blocking Client
There is an optional "blocking" client API that can be enabled:
```toml
[dependencies]
reqwest = { version = "0.11", features = ["blocking", "json"] }
```
```rust,no_run
use std::collections::HashMap;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::blocking::get("https://httpbin.org/ip")?
.json::<HashMap<String, String>>()?;
println!("{resp:#?}");
Ok(())
}
```
## Requirements
On Linux:
- OpenSSL with headers. See https://docs.rs/openssl for supported versions
and more details. Alternatively you can enable the `native-tls-vendored`
feature to compile a copy of OpenSSL.
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
rust_使用rust开发的http客户端代码.zip (76个子文件)
rust_使用rust开发的http客户端代码
Cargo.toml 7KB
.github
dependabot.yml 442B
workflows
ci.yml 9KB
FUNDING.yml 22B
src
cookie.rs 6KB
into_url.rs 3KB
lib.rs 11KB
dns
mod.rs 232B
trust_dns.rs 2KB
gai.rs 808B
resolve.rs 2KB
blocking
request.rs 32KB
mod.rs 3KB
multipart.rs 15KB
wait.rs 2KB
body.rs 10KB
client.rs 40KB
response.rs 13KB
redirect.rs 10KB
util.rs 3KB
tls.rs 19KB
response.rs 1KB
connect.rs 41KB
error.rs 10KB
async_impl
request.rs 33KB
mod.rs 426B
decoder.rs 13KB
multipart.rs 21KB
body.rs 9KB
upgrade.rs 2KB
h3_client
mod.rs 2KB
connect.rs 3KB
pool.rs 6KB
dns.rs 1KB
client.rs 89KB
response.rs 13KB
wasm
request.rs 14KB
mod.rs 1KB
multipart.rs 10KB
body.rs 9KB
client.rs 13KB
response.rs 5KB
proxy.rs 66KB
tests
brotli.rs 4KB
cookie.rs 6KB
multipart.rs 5KB
redirect.rs 11KB
blocking.rs 11KB
gzip.rs 4KB
upgrade.rs 2KB
client.rs 15KB
support
mod.rs 223B
delay_server.rs 4KB
server.rs 3KB
timeouts.rs 8KB
badssl.rs 2KB
deflate.rs 4KB
wasm_simple.rs 644B
proxy.rs 6KB
examples
h3_simple.rs 1KB
tor_socks.rs 832B
json_typed.rs 1KB
blocking.rs 882B
simple.rs 1KB
form.rs 843B
wasm_github_fetch
Cargo.toml 510B
webpack.config.js 790B
src
lib.rs 1KB
package.json 351B
package-lock.json 254KB
index.js 394B
.gitignore 41B
README.md 406B
json_dynamic.rs 1KB
.gitignore 29B
README.md 1KB
共 76 条
- 1
资源评论
极智视界
- 粉丝: 2w+
- 资源: 1459
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功