Last active: 9 months ago
rust async read tcp stream as header to string
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)
}