From 3a69dcdc9f487f79fdce82536c97b49ba7f216c7 Mon Sep 17 00:00:00 2001 From: edef Date: Sat, 3 Dec 2022 00:09:22 +0000 Subject: [PATCH] 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 Reviewed-by: Dmitri Shuralyov Reviewed-by: Damien Neil LUCI-TryBot-Result: Go LUCI --- src/net/http/cgi/host.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/net/http/cgi/host.go b/src/net/http/cgi/host.go index 073952a7bd4..085658ee7a6 100644 --- a/src/net/http/cgi/host.go +++ b/src/net/http/cgi/host.go @@ -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] }