#http-request #http

rust-netrc

netrc support for Rust with support for reqwest

3 releases

0.1.2 Oct 20, 2024
0.1.1 Jan 20, 2024
0.1.0 Jan 20, 2024

#1569 in Network programming

Download history 10880/week @ 2025-11-04 11749/week @ 2025-11-11 14197/week @ 2025-11-18 10337/week @ 2025-11-25 18319/week @ 2025-12-02 9831/week @ 2025-12-09 7884/week @ 2025-12-16 5220/week @ 2025-12-23 7510/week @ 2025-12-30 10833/week @ 2026-01-06 22273/week @ 2026-01-13 9047/week @ 2026-01-20 9903/week @ 2026-01-27 12522/week @ 2026-02-03 11831/week @ 2026-02-10 11710/week @ 2026-02-17

47,753 downloads per month
Used in 40 crates (6 directly)

MIT license

30KB
759 lines

netrc

A netrc library for Rust, with support for reqwest via reqwest-middleware.

reqwest-netrc

The reqwest-netrc crate is a middleware for reqwest to support the netrc file.

crates.io Documentation MIT licensed CI

Usage

To bring this crate into your repository, either add reqwest-netrc to your Cargo.toml, or run:

> cargo add reqwest-netrc

Example

The common scenario is to have a ~/.netrc file or the NETRC environement variable defined:

use reqwest::Client;
use reqwest_middleware::ClientBuilder;
use reqwest_netrc::NetrcMiddleware;

// ...

let client = ClientBuilder::new(Client::builder().build().unwrap())
    .with_init(NetrcMiddleware::new().unwrap())
    .build();

let res = client.get("https://domain.io/api/hello").send().await;

// ...

rust-netrc

The rust-netrc crate is a parser for the netrc files.

crates.io Documentation MIT licensed CI

Usage

To bring this crate into your repository, either add rust-netrc to your Cargo.toml, or run:

> cargo add rust-netrc

Example

use netrc::Netrc;

fn main() {
  let nrc = Netrc::new().unwrap();

  for (host, auth) in nrc.hosts {
      println!("{host}: {auth:?}");
  }
}

Contributing

Feedback and contributions are very welcome.

License

This project is licensed under MIT.

Dependencies

~0.8–3.5MB
~61K SLoC