Crates.io | tinyquest |
lib.rs | tinyquest |
version | 0.4.1 |
source | src |
created_at | 2020-09-12 16:09:01.497344 |
updated_at | 2020-11-27 19:51:03.428385 |
description | 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 |
homepage | |
repository | https://github.com/Iselk/LIM/tree/master/tinyquest |
max_upload_size | |
id | 287798 |
size | 30,863 |
Tinyquest is a Rust library aiming to give you a high-level, yet performant experience. The binary size is minimal, to make small bundled CLI's which need to make requests plausible.
To use tinyquest
, add this to your Cargo.toml
:
[dependencies]
tinyquest = "0.4.1"
Then, add this to your crate:
use tinyquest::{get, write};
fn main() {
// ...
}
Request a website, and print the 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),
};
}
};
}
This crate is licensed under the MIT license, and all contributions must also be.