#http-request #request #http #utility #networking

tinyquest

A *tiny* library used for making HTTP requests. It interacts with native-tls to be as small as possible, so it can be used in small CLI's

5 releases (3 breaking)

0.4.1 Nov 27, 2020
0.4.0 Nov 16, 2020
0.3.0 Sep 28, 2020
0.2.0 Sep 25, 2020
0.1.0 Sep 12, 2020

#380 in HTTP客户端

MIT license

20KB
472

Tinyquest

Tinyquest是一个Rust库,旨在为您提供高性能且高级的体验。二进制文件大小最小化,以创建需要发出请求的小型捆绑CLI。

用法

要使用 tinyquest,将以下内容添加到您的 Cargo.toml

[dependencies]
tinyquest = "0.4.1"

然后,将其添加到您的crate中

use tinyquest::{get, write};

fn main() {
  // ...
}

示例

请求一个网站,并打印HTML

use tinyquest::get;

fn main() {
    match tinyquest::get("rust-lang.org", "my-application/0.1.0") {
        Err(err) => eprintln!("Failed: {:?}", err),
        Ok(mut result) => {
            match result.follow_redirects() {
                Ok(s) => {
                    let (parts, body) = s.into_parts();
                    println!(
                        "Headers: '{:#?}'\n\
                        Body: '{}'",
                        parts.headers,
                        String::from_utf8_lossy(&body),
                    );
                }
                Err(err) => eprintln!("Failed: {:#?}", err),
            };
        }
    };
}

许可证

此crate采用MIT许可证,所有贡献也必须如此。

依赖项

~0.6–10MB
~94K SLoC