~zethra/stargazer

daf76cda7c16b662ebcb9ed58a4825a4eee39239 — Ben Aaron Goldberg a month ago 6f7685d
cgi: Add leading slashed to paths

Add leading slashes to the SCRIPT_NAME and PATH_INFO CGI vars so that
they're consistent with SCGI and general convention as I understand it.
1 files changed, 8 insertions(+), 3 deletions(-)

M src/cgi.rs
M src/cgi.rs => src/cgi.rs +8 -3
@@ 38,7 38,7 @@ use futures_lite::{
use is_executable::IsExecutable;
use log::{debug, error};
use sha2::{Digest, Sha256};
use std::time::Duration;
use std::{ffi::{OsStr, OsString}, time::Duration};
use std::{collections::HashMap, net::IpAddr};
use std::{
    io::ErrorKind,


@@ 96,8 96,13 @@ pub async fn serve_cgi<'a>(
        common_vars(domain, req, remote_addr, server_port, &session).await?,
    );
    cmd.env("GATEWAY_INTERFACE", "CGI/1.1");
    cmd.env("SCRIPT_NAME", script_name);
    cmd.env("PATH_INFO", path_info);
    fn add_leading_slash(s: &OsStr) -> OsString {
        let mut new = OsString::from("/");
        new.push(s);
        new
    }
    cmd.env("SCRIPT_NAME", add_leading_slash(script_name.as_os_str()));
    cmd.env("PATH_INFO", add_leading_slash(path_info.as_os_str()));
    cmd.stdout(Stdio::piped());
    cmd.stderr(Stdio::piped());