Added redirect and cgienv

This commit is contained in:
int 80h
2020-05-13 21:42:00 -04:00
parent 929a11a91c
commit dfae3705c4
12 changed files with 178 additions and 130 deletions

View File

@@ -1,14 +1,20 @@
use std::collections::HashMap;
use std::io;
use std::path::{PathBuf};
use std::path::PathBuf;
use std::process::Command;
use url::Url;
use crate::status::Status;
use crate::config;
use crate::conn;
use crate::logger;
use crate::status::Status;
pub async fn cgi(mut con: conn::Connection, path: PathBuf, url: Url) -> Result<(), io::Error> {
pub async fn cgi(
mut con: conn::Connection,
srv: &config::ServerCfg,
path: PathBuf,
url: Url,
) -> Result<(), io::Error> {
let mut envs = HashMap::new();
envs.insert("GATEWAY_INTERFACE", "CGI/1.1");
envs.insert("GEMINI_URL", url.as_str());
@@ -26,6 +32,12 @@ pub async fn cgi(mut con: conn::Connection, path: PathBuf, url: Url) -> Result<(
envs.insert("QUERY_STRING", q);
}
if srv.cgienv.len() != 0 {
for (k, v) in srv.cgienv.iter() {
envs.insert(&k, &v);
}
};
let cmd = Command::new(path.to_str().unwrap())
.env_clear()
.envs(&envs)