#header #header-parser #parser #development #web-kit

reqwest-header

reqwest crate 的头部信息解析器

1 个不稳定版本

0.1.0 2023年6月27日

2441开发工具

MIT 许可证

6KB

reqwest crate 的头部信息解析器

Crates.io Rust license

示例

#[tokio::main]
async fn main() {
    let header_data = r##"
            GET /api/v1/crates?page=1&per_page=10&q={} HTTP/2
            Host: crates.io
            User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.5249.119 Safari/537.36
            Referer: https://crates.io/search?q=doe
            Sec-Fetch-Site: same-origin
            Sec-Fetch-Mode: cors
            Sec-Fetch-Dest: empty
            "##.format(name);
    let info = reqwest_header::parse_to_reqwest_header(&header_data).unwrap();
    let cilent = reqwest::Client::new();
    let response = cilent
                    .get(info.url)
                    .headers(info.header)
                    .send()
                    .await
                    .unwrap();
    let test = response.text().await.unwrap().to_string();
}

依赖项

~3–17MB
~220K SLoC