]> Cypherpunks.ru repositories - gostls13.git/commitdiff
net/http/cgi: set SERVER_PORT to 443 when req.TLS != nil
authoredef <edef@edef.eu>
Sat, 3 Dec 2022 00:09:22 +0000 (00:09 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 4 Oct 2023 16:50:58 +0000 (16:50 +0000)
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>

src/net/http/cgi/host.go

index 073952a7bd40f15bb75cba793c26537f55391923..085658ee7a6d373095f94dcb0d998a1d1aa01980 100644 (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]
        }