Added timeout to readme

This commit is contained in:
int 80h
2020-05-22 15:51:48 -04:00
parent 77fdc18097
commit bec2d0e858
3 changed files with 11 additions and 5 deletions

View File

@@ -132,7 +132,12 @@ pub async fn scgi(addr: String, u: url::Url, mut con: conn::Connection, srv: &co
stream.flush().await?;
let mut buf = vec![];
stream.read_to_end(&mut buf).await?;
if let Err(_) = tokio::time::timeout(
tokio::time::Duration::from_secs(5), stream.read_to_end(&mut buf)).await {
logger::logger(con.peer_addr, Status::CGIError, u.as_str());
con.send_status(Status::CGIError, None).await?;
return Ok(());
}
let req = String::from_utf8_lossy(&buf[..]);
if !check(req.as_bytes()[0], con.peer_addr, u) {
con.send_status(Status::CGIError, None).await?;