From 2eda21ec6d44fa2f57e72ef0f02ea29c902d871d Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Fri, 10 Jan 2020 17:02:11 -0700 Subject: [PATCH] http: Remove {...query_string} placeholder, in favor of {...query} I am not sure if the query_string one is necessary or useful yet. We can always add it later if needed. --- caddyconfig/httpcaddyfile/httptype.go | 2 +- modules/caddyhttp/caddyhttp.go | 2 -- modules/caddyhttp/replacer.go | 5 ----- modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go | 2 +- 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/caddyconfig/httpcaddyfile/httptype.go b/caddyconfig/httpcaddyfile/httptype.go index 33a37d31a..bec504599 100644 --- a/caddyconfig/httpcaddyfile/httptype.go +++ b/caddyconfig/httpcaddyfile/httptype.go @@ -101,7 +101,7 @@ func (st ServerType) Setup(originalServerBlocks []caddyfile.ServerBlock, "{scheme}", "{http.request.scheme}", "{file}", "{http.request.uri.path.file}", "{dir}", "{http.request.uri.path.dir}", - "{query}", "{http.request.uri.query_string}", + "{query}", "{http.request.uri.query}", ) for _, segment := range sb.block.Segments { for i := 0; i < len(segment); i++ { diff --git a/modules/caddyhttp/caddyhttp.go b/modules/caddyhttp/caddyhttp.go index 8ff2fb609..ab217cbd4 100644 --- a/modules/caddyhttp/caddyhttp.go +++ b/modules/caddyhttp/caddyhttp.go @@ -66,7 +66,6 @@ func init() { // `{http.request.orig.path.dir}` | The request's original directory // `{http.request.orig.path.file}` | The request's original filename // `{http.request.orig.uri.path}` | The request's original path -// `{http.request.orig.uri.query_string}` | The request's original full query string (with `?`) // `{http.request.orig.uri.query}` | The request's original query string (without `?`) // `{http.request.orig.uri}` | The request's original URI // `{http.request.port}` | The port part of the request's Host header @@ -79,7 +78,6 @@ func init() { // `{http.request.uri.path.dir}` | The directory, excluding leaf filename // `{http.request.uri.path.file}` | The filename of the path, excluding directory // `{http.request.uri.path}` | The path component of the request URI -// `{http.request.uri.query_string}` | The full query string (with `?`) // `{http.request.uri.query.*}` | Individual query string value // `{http.request.uri.query}` | The query string (without `?`) // `{http.request.uri}` | The full request URI diff --git a/modules/caddyhttp/replacer.go b/modules/caddyhttp/replacer.go index 09837be57..cea820d05 100644 --- a/modules/caddyhttp/replacer.go +++ b/modules/caddyhttp/replacer.go @@ -104,8 +104,6 @@ func addHTTPVarsToReplacer(repl *caddy.Replacer, req *http.Request, w http.Respo return dir, true case "http.request.uri.query": return req.URL.RawQuery, true - case "http.request.uri.query_string": - return "?" + req.URL.RawQuery, true // original request, before any internal changes case "http.request.orig_method": @@ -128,9 +126,6 @@ func addHTTPVarsToReplacer(repl *caddy.Replacer, req *http.Request, w http.Respo case "http.request.orig_uri.query": or, _ := req.Context().Value(OriginalRequestCtxKey).(http.Request) return or.URL.RawQuery, true - case "http.request.orig_uri.query_string": - or, _ := req.Context().Value(OriginalRequestCtxKey).(http.Request) - return "?" + or.URL.RawQuery, true } // hostname labels diff --git a/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go b/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go index f78a405d1..ca0d6ccad 100644 --- a/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go +++ b/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go @@ -149,7 +149,7 @@ func parsePHPFastCGI(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error }), } rewriteHandler := rewrite.Rewrite{ - URI: "{http.matchers.file.relative}{http.request.uri.query_string}", + URI: "{http.matchers.file.relative}?{http.request.uri.query}", } rewriteRoute := caddyhttp.Route{ MatcherSetsRaw: []caddy.ModuleMap{rewriteMatcherSet},