Created
January 30, 2024 06:22
-
-
Save DefectingCat/995da71c8070e4d444ddb425b37afac3 to your computer and use it in GitHub Desktop.
rust async read tcp stream as header to string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub async fn read_headers<R>(reader: R) -> Result<String> | |
where | |
R: AsyncRead + std::marker::Unpin, | |
{ | |
let mut request_string = String::new(); | |
let mut reader = BufReader::new(reader); | |
loop { | |
let byte = reader.read_line(&mut request_string).await?; | |
if byte < 3 { | |
break; | |
} | |
} | |
Ok(request_string) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment