mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-16 21:56:40 -05: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
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue