3 releases

0.1.2 Jan 6, 2024
0.1.1 Aug 7, 2022
0.1.0 Aug 7, 2022

#208 in HTTP client

Download history 197/week @ 2023-12-23 313/week @ 2023-12-30 134/week @ 2024-01-06 34/week @ 2024-01-13 10/week @ 2024-01-20 7/week @ 2024-01-27 2/week @ 2024-02-03 85/week @ 2024-02-10 49/week @ 2024-02-17 97/week @ 2024-02-24 30/week @ 2024-03-02 55/week @ 2024-03-09 55/week @ 2024-03-16 23/week @ 2024-03-23 70/week @ 2024-03-30 6/week @ 2024-04-06

160 downloads per month
Used in gha-toolkit

MIT license

9KB
112 lines

reqwest-retry-after

Crates.io docs.rs Crates.io

reqwest-retry-after is a library that adds support for the Retry-After header in reqwest, using reqwest_middleware.

Usage

Simply pass RetryAfterMiddleware to the ClientWithMiddleware builder.

use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
use reqwest_retry_after::RetryAfterMiddleware;

let client = ClientBuilder::new(reqwest::Client::new())
    .with(RetryAfterMiddleware::new())
    .build();

lib.rs:

reqwest-retry-after

reqwest-retry-after is a library that adds support for the Retry-After header in reqwest, using reqwest_middleware.

Usage

Simply pass RetryAfterMiddleware to the ClientWithMiddleware builder.

use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
use reqwest_retry_after::RetryAfterMiddleware;

let client = ClientBuilder::new(reqwest::Client::new())
    .with(RetryAfterMiddleware::new())
    .build();

Notes

A client constructed with RetryAfterMiddleware will apply the Retry-After header to all future requests, regardless of domain or URL. This means that if you query one URL which sets a Retry-After, and then query a different URL that has no ratelimiting, the Retry-After will be applied to the new URL.

If you need this functionality, consider creating a seperate client for each endpoint.

Dependencies

~6–20MB
~290K SLoC