Skip to content

net/http: Server with TLS consumes "Upgrade" header #30204

Closed
@ssttevee

Description

@ssttevee

What version of Go are you using (go version)?

$ go version
go version go1.12rc1 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/steve/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/steve/.gvm/pkgsets/go1.12rc1/global"
GOPROXY=""
GORACE=""
GOROOT="/home/steve/.gvm/gos/go1.12rc1"
GOTMPDIR=""
GOTOOLDIR="/home/steve/.gvm/gos/go1.12rc1/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/steve/http-test/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build314515568=/tmp/go-build -gno-record-gcc-switches"

What did you do?

go run the following code followed by a curl with a Upgrade header.

package main

import (
	"log"
	"net/http"
)

func main() {
	var handler http.HandlerFunc = func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte(r.Header.Get("Upgrade")))
	}

	log.Fatal(http.ListenAndServeTLS(":8443", "rsa.crt", "rsa.key", handler))
}

What did you expect to see?

$ curl -k -i --header "Upgrade: websocket" "https://localhost:8443/"
HTTP/2 200
content-length: 9

websocket

What did you see instead?

$ curl -k -i --header "Upgrade: websocket" "https://localhost:8443/"
HTTP/2 200
content-length: 0


Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions