Watchdog - enable forwarding of HTTP headers via CGI-like env vars.

This commit is contained in:
Alex
2017-05-09 09:13:42 +01:00
parent 201d2c20de
commit cc0d351e69
3 changed files with 88 additions and 0 deletions

View File

@ -51,6 +51,16 @@ func pipeRequest(config *WatchdogConfig, w http.ResponseWriter, r *http.Request)
}
targetCmd := exec.Command(parts[0], parts[1:]...)
if config.cgiHeaders {
envs := os.Environ()
for k, v := range r.Header {
kv := fmt.Sprintf("Http_%s=%s", k, v[0])
envs = append(envs, kv)
}
targetCmd.Env = envs
}
writer, _ := targetCmd.StdinPipe()
var out []byte