diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2020-04-08 10:43:08 -0600 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2020-04-08 10:44:40 -0600 |
commit | e30deedcc1490e1fc73b375a0d3147e625aa7472 (patch) | |
tree | 0821660fb75fc0d16c22c79940e72d3dbe6c12a8 /modules/caddyhttp | |
parent | fbd9515d3523a24e83b0e671f2fc0e17dcdd9b19 (diff) |
caddyhttp: Return port placeholders as ints
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r-- | modules/caddyhttp/replacer.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/caddyhttp/replacer.go b/modules/caddyhttp/replacer.go index f55bb0a..51fe67f 100644 --- a/modules/caddyhttp/replacer.go +++ b/modules/caddyhttp/replacer.go @@ -85,6 +85,9 @@ func addHTTPVarsToReplacer(repl *caddy.Replacer, req *http.Request, w http.Respo return host, true case "http.request.port": _, port, _ := net.SplitHostPort(req.Host) + if portNum, err := strconv.Atoi(port); err == nil { + return portNum, true + } return port, true case "http.request.hostport": return req.Host, true @@ -98,6 +101,9 @@ func addHTTPVarsToReplacer(repl *caddy.Replacer, req *http.Request, w http.Respo return host, true case "http.request.remote.port": _, port, _ := net.SplitHostPort(req.RemoteAddr) + if portNum, err := strconv.Atoi(port); err == nil { + return portNum, true + } return port, true // current URI, including any internal rewrites |