use color_eyre::Result;
mod concuring;
mod request;
use concuring::Concuring;
use request::RequestBuilder;
fn main() -> Result<()> {
tracing_subscriber::fmt()
.with_env_filter(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("concuring=debug")),
)
.init();
let mut client = Concuring::<8>::new()?;
let request = RequestBuilder::get("http://127.0.0.1:7777/")
.unwrap()
.append_header("Connection", "close")
.unwrap()
.build_without_body();
client
.try_submit(1, request)
.expect("has space for 1 request");
client.wait().expect("should get 1 resp at least");
assert!(client.wait().is_none());
while let Some(resp) = client.finished_responses.pop_front() {
println!("Request {} finalized", resp.0);
let resp = resp.1.expect("success");
eprintln!("got resp with body {}", resp.body().len());
}
Ok(())
}