don't round-trip CGI response through UTF-8

this fixes sending binary files from a CGI script
This commit is contained in:
Melody Horn
2020-11-11 16:06:28 -07:00
committed by int 80h
parent 7be0d5fa1f
commit f9c41edcb4

View File

@@ -137,13 +137,13 @@ pub async fn cgi(
con.send_status(Status::CGIError, None).await?; con.send_status(Status::CGIError, None).await?;
return Ok(()); return Ok(());
} }
let cmd = String::from_utf8(cmd.stdout).unwrap(); let cmd = cmd.stdout;
if !check(cmd.as_bytes()[0], con.peer_addr, url) { if !check(cmd[0], con.peer_addr, url) {
con.send_status(Status::CGIError, None).await?; con.send_status(Status::CGIError, None).await?;
return Ok(()); return Ok(());
} }
con.send_raw(cmd.as_bytes()).await?; con.send_raw(&cmd).await?;
return Ok(()); return Ok(());
} }