1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#![allow(unused_imports)]
use hyper::{body::HttpBody, Client};
#[cfg(feature = "client")]
use hyperlocal::{UnixClientExt, Uri};
use std::error::Error;
use tokio::io::{self, AsyncWriteExt as _};
#[tokio::main]
#[cfg(feature = "client")]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
let url = Uri::new("/tmp/hyperlocal.sock", "/").into();
let client = Client::unix();
let mut response = client.get(url).await?;
while let Some(next) = response.data().await {
let chunk = next?;
io::stdout().write_all(&chunk).await?;
}
Ok(())
}
#[cfg(not(feature = "client"))]
fn main() {}
|