reqwest README

The project's README from github.com/seanmonstar/reqwest. As one markdown file: README.md.

reqwest

crates.io Documentation MIT/Apache-2 licensed CI

An ergonomic, batteries-included HTTP Client for Rust.

Example

This asynchronous example uses Tokio and enables some optional features, so your Cargo.toml could look like this:

[dependencies]
reqwest = { version = "0.13", features = ["json"] }
tokio = { version = "1", features = ["full"] }

And then the code:

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(())
}

Commercial Support

For private advice, support, reviews, access to the maintainer, and the like, reach out for commercial support.

Requirements

By default, Reqwest uses rustls, but when the native-tls feature is enabled it will use the operating system TLS framework if available, meaning Windows and macOS. On Linux, it will use the available OpenSSL (see https://docs.rs/openssl for supported versions and more details) or fail to build if not found. Alternatively you can enable the native-tls-vendored feature to compile a copy of OpenSSL.

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Sponsors

Support this project by becoming a sponsor.

reqwest (seanmonstar/reqwest)

Searching Database…

11.9K ·GitHub
这是什么东西?Reqwest 是一个为 Rust 打造的好用又强大的 HTTP 客户端库——接口顺手、功能齐全,HTTP 客户端常见的需求开箱即用。
它是在我的 Rust 代码里调用的库,还是单独运行的工具?它是一个 Rust crate(软件包):把它作为依赖加到你自己的项目里,然后在代码中调用——没有需要单独安装或运行的可执行程序。
我该怎么用它发请求?把 reqwest 加进你的 Cargo.toml,启用你需要的功能特性,然后就可以发请求了——可以在 Tokio 上异步发送,也可以用内置的阻塞式客户端,不想碰异步就用它。
我还需要额外准备别的东西吗,比如 Tokio 或者 TLS 库?异步 API 依赖 Tokio。至于 HTTPS,reqwest 默认使用 rustls,所以不需要配置系统的 TLS 环境;启用 native-tls 功能则会改用 Windows 和 macOS 系统自带的 TLS 框架。
编译时有什么坑需要提前知道吗?在 Linux 上使用 native-tls 时,reqwest 会链接系统的 OpenSSL,如果系统没装它,编译就会失败;native-tls-vendored 功能可以绕过这个问题,它会自己编译一份 OpenSSL。
除了发普通请求,它还自带哪些功能?普通请求体、JSON、urlencoded 表单、multipart 上传、cookie 存储、HTTP 代理、可自定义的重定向策略以及 HTTPS 都内置支持——另外还可以自由选择异步或阻塞式客户端。
它能在浏览器里运行吗?可以——WASM 是官方支持的目标平台,你可以把 reqwest 编译成 WebAssembly,在网页里使用同一套客户端 API。
如果 GitHub issues 之外还需要帮助,有付费支持吗?有——作者通过 README 里的赞助链接提供商业支持,包括私下咨询、代码审查,以及直接联系维护者。
What are similar projects?request, got, guzzle, hyper, actix-web, aiohttp, cpp-httplib, pingora
Size
2.8 MB
Stars
11.9K
Age
10y
Commits · 90 Days