mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-22 01:29:59 +08:00
Merge remote-tracking branch 'upstream/master'
Conflicts: middleware/fastcgi/fastcgi.go
This commit is contained in:
@ -167,9 +167,17 @@ func (h Handler) buildEnv(r *http.Request, rule Rule, fpath string) (map[string]
|
||||
}
|
||||
|
||||
// Strip PATH_INFO from SCRIPT_NAME
|
||||
indexPathInfo := strings.LastIndex(scriptName, pathInfo)
|
||||
if indexPathInfo != -1 {
|
||||
scriptName = scriptName[:indexPathInfo]
|
||||
scriptName = strings.TrimSuffix(scriptName, pathInfo)
|
||||
|
||||
// Get the request URI. The request URI might be as it came in over the wire,
|
||||
// or it might have been rewritten internally by the rewrite middleware (see issue #256).
|
||||
// If it was rewritten, there will be a header indicating the original URL,
|
||||
// which is needed to get the correct RequestURI value for PHP apps.
|
||||
const internalRewriteFieldName = "Caddy-Rewrite-Original-URI"
|
||||
reqURI := r.URL.RequestURI()
|
||||
if origURI := r.Header.Get(internalRewriteFieldName); origURI != "" {
|
||||
reqURI = origURI
|
||||
r.Header.Del(internalRewriteFieldName)
|
||||
}
|
||||
|
||||
// Some variables are unused but cleared explicitly to prevent
|
||||
@ -198,7 +206,7 @@ func (h Handler) buildEnv(r *http.Request, rule Rule, fpath string) (map[string]
|
||||
"DOCUMENT_ROOT": h.AbsRoot,
|
||||
"DOCUMENT_URI": docURI,
|
||||
"HTTP_HOST": r.Host, // added here, since not always part of headers
|
||||
"REQUEST_URI": r.URL.RequestURI(),
|
||||
"REQUEST_URI": reqURI,
|
||||
"SCRIPT_FILENAME": scriptFilename,
|
||||
"SCRIPT_NAME": scriptName,
|
||||
}
|
||||
|
Reference in New Issue
Block a user