simplist: plain and simple http.
a plain and simple http library for when you just want to make a darn request!
this crate is a super thin and lightweight wrapper on top of hyper, and provides apis for futures-based async, traditional sync and async-await models.
HttpClient
is the primary interface for making http requests.
features.
nightly
: when turned on, simplist will perform about one allocation per request by usingimpl Future
, which is currently an experimental feature. when compiling for the stable compiler, simplist needs to box some future types because they cannot be named.scramble
: when turned on, simplist will compile out most error messages, replacing them with an empty string.
if you're using a nightly compiler, turn on the nightly feature in your cargo.toml
!
simplist = { version = "0.0.5", features = ["nightly"] }
examples.
asynchronous, with await notation.
use simplist::HttpClient;
let http = HttpClient::new(handle);
let html = await http.get_string("https://hinaria.com")?;
println!("{:?}", html);
// => "<!doctype html>\n \n \n ..."
asynchronous, with future callbacks.
use simplist::HttpClient;
let http = HttpClient::new(handle);
let future = http.get_string("https://hinaria.com").and_then(|html| {
println!("{:?}", html);
Ok(())
}).map_err(|_| ());
handle.spawn(future);
// => "<!doctype html>\n \n \n ..."
synchronous.
use simplist::HttpSyncClient;
let http = HttpSyncClient::new(handle);
let html = http.get_string("https://hinaria.com")?;
println!("{:?}", html);
// => "<!doctype html>\n \n \n ..."