From 4c84a2c76f0305cac17fb148a413f99a841f711c Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Thu, 12 Jan 2023 02:47:42 -0800 Subject: [PATCH] Print out html --- src/main.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 695f1ef..e40f21f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,10 @@ use std::env::args; use anyhow::anyhow; -use hyper::{Request, Uri}; use hyper::Body; +use hyper::{Request, Uri}; use tokio::net::TcpStream; - #[tokio::main] async fn main() -> anyhow::Result<()> { let arguments: Vec = args().collect(); @@ -34,9 +33,13 @@ async fn main() -> anyhow::Result<()> { .header(hyper::header::HOST, authority.as_str()) .body(Body::from(""))?; - let mut res = sender.send_request(req).await?; + let res = sender.send_request(req).await?; + let body = res.into_body(); + let body_bytes = hyper::body::to_bytes(body).await?; - println!("{:?}", res); + let body_text = String::from_utf8(body_bytes.to_vec())?; + + println!("{}", body_text); Ok(()) }