1
0
mirror of https://github.com/golang/go synced 2024-11-23 17:50:06 -07:00

net/http/cgi: set SERVER_PORT to 443 when req.TLS != nil

A hostname without a port leaves the port implied by the protocol.
For HTTPS, the implied port is 443, not 80.

Change-Id: I873a076068f84c8041abf10a435d9499635730a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/454975
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
edef 2022-12-03 00:09:22 +00:00 committed by Gopher Robot
parent 68a12a8023
commit 3a69dcdc9f

View File

@ -132,6 +132,9 @@ func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
}
port := "80"
if req.TLS != nil {
port = "443"
}
if matches := trailingPort.FindStringSubmatch(req.Host); len(matches) != 0 {
port = matches[1]
}