control/controlhttp: fix header case-sensitivity

Change-Id: I49269bc969a80382997ec5c9de33c4f56d9dc787
Signed-off-by: Matthias Gabriel <matthias.gabriel@etit.tu-chemnitz.de>
pull/6957/head
Matthias Gabriel 2 years ago committed by Brad Fitzpatrick
parent 61dfbc0a6e
commit 355c3b2be7

@ -12,6 +12,7 @@ import (
"io" "io"
"net" "net"
"net/http" "net/http"
"strings"
"time" "time"
"nhooyr.io/websocket" "nhooyr.io/websocket"
@ -35,7 +36,7 @@ func AcceptHTTP(ctx context.Context, w http.ResponseWriter, r *http.Request, pri
} }
func acceptHTTP(ctx context.Context, w http.ResponseWriter, r *http.Request, private key.MachinePrivate, earlyWrite func(protocolVersion int, w io.Writer) error) (_ *controlbase.Conn, retErr error) { func acceptHTTP(ctx context.Context, w http.ResponseWriter, r *http.Request, private key.MachinePrivate, earlyWrite func(protocolVersion int, w io.Writer) error) (_ *controlbase.Conn, retErr error) {
next := r.Header.Get("Upgrade") next := strings.ToLower(r.Header.Get("Upgrade"))
if next == "" { if next == "" {
http.Error(w, "missing next protocol", http.StatusBadRequest) http.Error(w, "missing next protocol", http.StatusBadRequest)
return nil, errors.New("no next protocol in HTTP request") return nil, errors.New("no next protocol in HTTP request")

Loading…
Cancel
Save