fake_headers

Crates.iofake_headers
lib.rsfake_headers
version0.0.5
sourcesrc
created_at2023-09-08 10:02:35.444607
updated_at2023-09-08 11:14:48.359146
descriptionGenerate fake HTTP headers for your HTTP requests.
homepagehttps://github.com/shhossain/rust-fake-headers
repositoryhttps://github.com/shhossain/rust-fake-headers
max_upload_size
id966896
size11,035
sifat (shhossain)

documentation

README

Fake Headers for rust

This is created from python fake_headers module. It generates random user-agent and other headers for your http requests.

Usage

use fake_headers::Headers;
use reqwest::header::HeaderMap;

fn main() {

    let fheaders = Headers {
        browser: 'chrome', # `chrome`, `firefox` or `opera`
        os: `win`, # `win`, `linux` or `mac`
        headers: true,
    };

    let generated_headers = fheaders.generate();
    println!("{:?}", generated_headers);

    // or get random header
    let random_header = Headers::default().generate();
    println!("{:?}", random_header);

    // add headers to reqwest
    let mut headers = reqwest::header::HeaderMap::new();
    for (key, value) in random_header {
        let header_name = reqwest::header::HeaderName::from_bytes(key.as_bytes()).unwrap();
        let header_value = reqwest::header::HeaderValue::from_str(&value).unwrap();
        headers.insert(header_name, header_value);
    }

    let client = reqwest::Client::builder()
        .default_headers(headers)
        .build()
        .unwrap();

    let res = client.get("https://httpbin.org/headers").send().unwrap();
    println!("{:?}", res.text().unwrap());
}
Commit count: 8

cargo fmt