13 releases

0.5.1 Jul 18, 2021
0.5.0 Jan 9, 2021
0.4.3 Nov 18, 2020
0.3.1 Jul 20, 2020
0.1.1 Dec 26, 2018

#262 in Configuration

Download history 1/week @ 2022-12-01 1/week @ 2022-12-08 13/week @ 2022-12-15 3/week @ 2022-12-29 4/week @ 2023-01-05 1/week @ 2023-01-19 5/week @ 2023-01-26 6/week @ 2023-02-02 26/week @ 2023-02-09 39/week @ 2023-02-16 1/week @ 2023-03-02 26/week @ 2023-03-09

72 downloads per month

Apache-2.0 OR MIT

3.5K SLoC


Travis Build Status

A helper to create configured reqwest client and a helper to keep one around with up to date configuration. It is part of the spirit system.

See the docs and the examples.


Licensed under either of

at your option.


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.


This helps with configuring the [reqwest] [Client].

This is part of the spirit system.

There are two levels of support. The first one is just letting the Spirit to load the [ReqwestClient] configuration fragment and calling one of its methods to create the [Client] or others.

The other, more convenient way, is pairing an extractor function with the [AtomicClient][futures::AtomicClient] and letting Spirit keep an up to date version of [Client] in there at all times.

The split and features

The [ReqwestClient] lives at the top of the crate. However, [reqwest] provides both blocking and async flavours of the HTTP client. For that reason, this crate provides two submodules, each with the relevant support (note that the name of the async one is [futures], because async is a keyword). The pipeline is configured with the relevant IntoClient transformation and installed into the relevant AtomicClient.

Features enable parts of the functionality here and correspond to some of the features of [reqwest]. In particular:

  • gzip: The enable-gzip configuration option.
  • brotli: The enable-brotli configuration option.
  • native-tls: The tls-identity, tls-identity-password and tls-accept-invalid-hostnames options.
  • blocking: The whole [blocking] module and methods for creating the blocking client and builder.

Porting from the 0.3 version

  • You may need to enable certain features (if you want to keep using the blocking API, you need the blocking feature, but you also may want the native-tls and gzip features to get the same feature coverage).
  • Part of what you used moved to the submodule, but otherwise should have same or similar API
  • The pipeline needs the addition of .transform(IntoClient) between config extraction and installation, to choose if you are interested in blocking or async flavour.


# #[cfg(feature = "blocking")] mod example {
use serde::Deserialize;
use spirit::{Empty, Pipeline, Spirit};
use spirit::prelude::*;
use spirit_reqwest::ReqwestClient;
// Here we choose if we want blocking or async (futures module)
use spirit_reqwest::blocking::{AtomicClient, IntoClient};

#[derive(Debug, Default, Deserialize)]
struct Cfg {
    client: ReqwestClient,

impl Cfg {
    fn client(&self) -> ReqwestClient {

# pub
fn main() {
    let client = AtomicClient::unconfigured(); // Get a default config before we get configured
    Spirit::<Empty, Cfg>::new()
            Pipeline::new("http client")
                // Choose if you want blocking or async client
                // (eg. spirit_reqwest::blocking::IntoClient or
                // spirit_reqwest::futures::IntoClient)
                // Choose where to store it
        .run(move |_| {
            let page = client
            println!("{}", page);
# }
# #[cfg(not(feature = "blocking"))] mod example { pub fn main() {} }
# fn main() { example::main() }


~327K SLoC