Skip to content

Commit

Permalink
fastcgi: Avoid changing scriptName when not necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
francislavoie committed Nov 1, 2020
1 parent 05a34db commit 0d91a36
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,29 +195,28 @@ func (t Transport) buildEnv(r *http.Request) (map[string]string, error) {
}

fpath := r.URL.Path
scriptName := fpath

docURI := fpath
// split "actual path" from "path info" if configured
var docURI, pathInfo string
var pathInfo string
if splitPos := t.splitPos(fpath); splitPos > -1 {
docURI = fpath[:splitPos]
pathInfo = fpath[splitPos:]
} else {
docURI = fpath

// Strip PATH_INFO from SCRIPT_NAME
scriptName = strings.TrimSuffix(scriptName, pathInfo)
}
scriptName := fpath

// Try to grab the path remainder from a file matcher if we didn't
// get a split result here.
// Try to grab the path remainder from a file matcher
// if we didn't get a split result here.
// See https://github.com/caddyserver/caddy/issues/3718
if pathInfo == "" {
if remainder, ok := repl.Get("http.matchers.file.remainder"); ok {
pathInfo = remainder.(string)
}
}

// Strip PATH_INFO from SCRIPT_NAME
scriptName = strings.TrimSuffix(scriptName, pathInfo)

// SCRIPT_FILENAME is the absolute path of SCRIPT_NAME
scriptFilename := filepath.Join(root, scriptName)

Expand Down

0 comments on commit 0d91a36

Please sign in to comment.