mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-23 00:56:45 +01:00
caddyhttp: Return port placeholders as ints
This commit is contained in:
parent
fbd9515d35
commit
e30deedcc1
1 changed files with 6 additions and 0 deletions
|
@ -85,6 +85,9 @@ func addHTTPVarsToReplacer(repl *caddy.Replacer, req *http.Request, w http.Respo
|
||||||
return host, true
|
return host, true
|
||||||
case "http.request.port":
|
case "http.request.port":
|
||||||
_, port, _ := net.SplitHostPort(req.Host)
|
_, port, _ := net.SplitHostPort(req.Host)
|
||||||
|
if portNum, err := strconv.Atoi(port); err == nil {
|
||||||
|
return portNum, true
|
||||||
|
}
|
||||||
return port, true
|
return port, true
|
||||||
case "http.request.hostport":
|
case "http.request.hostport":
|
||||||
return req.Host, true
|
return req.Host, true
|
||||||
|
@ -98,6 +101,9 @@ func addHTTPVarsToReplacer(repl *caddy.Replacer, req *http.Request, w http.Respo
|
||||||
return host, true
|
return host, true
|
||||||
case "http.request.remote.port":
|
case "http.request.remote.port":
|
||||||
_, port, _ := net.SplitHostPort(req.RemoteAddr)
|
_, port, _ := net.SplitHostPort(req.RemoteAddr)
|
||||||
|
if portNum, err := strconv.Atoi(port); err == nil {
|
||||||
|
return portNum, true
|
||||||
|
}
|
||||||
return port, true
|
return port, true
|
||||||
|
|
||||||
// current URI, including any internal rewrites
|
// current URI, including any internal rewrites
|
||||||
|
|
Loading…
Reference in a new issue