1
0
mirror of https://github.com/golang/go synced 2024-11-18 06:14:46 -07:00

cmd/present: fix origin mismatch for websocket when using HTTPS

Fixes golang/go#31328

Change-Id: Ib190f42970d5b203e3f1fbf997aa896cf624bf91
Reviewed-on: https://go-review.googlesource.com/c/tools/+/171118
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Daved 2019-04-07 13:13:06 -07:00 committed by Brad Fitzpatrick
parent 539cdc44f8
commit 18e3458ac9

View File

@ -77,6 +77,11 @@ func main() {
origin := &url.URL{Scheme: "http"}
if *originHost != "" {
if strings.HasPrefix(*originHost, "https://") {
*originHost = strings.TrimPrefix(*originHost, "https://")
origin.Scheme = "https"
}
*originHost = strings.TrimPrefix(*originHost, "http://")
origin.Host = net.JoinHostPort(*originHost, port)
} else if ln.Addr().(*net.TCPAddr).IP.IsUnspecified() {
name, _ := os.Hostname()