node: relax websocket connection header check (#21646)

This makes it accept the "upgrade,keep-alive" header value, which
apparently is a thing.
This commit is contained in:
Felix Lange
2020-10-07 20:05:14 +02:00
committed by GitHub
parent 716864deba
commit 015e78928a
2 changed files with 16 additions and 1 deletions

View File

@@ -73,6 +73,21 @@ func TestWebsocketOrigins(t *testing.T) {
assert.Error(t, err)
}
// TestIsWebsocket tests if an incoming websocket upgrade request is handled properly.
func TestIsWebsocket(t *testing.T) {
r, _ := http.NewRequest("GET", "/", nil)
assert.False(t, isWebsocket(r))
r.Header.Set("upgrade", "websocket")
assert.False(t, isWebsocket(r))
r.Header.Set("connection", "upgrade")
assert.True(t, isWebsocket(r))
r.Header.Set("connection", "upgrade,keep-alive")
assert.True(t, isWebsocket(r))
r.Header.Set("connection", " UPGRADE,keep-alive")
assert.True(t, isWebsocket(r))
}
func createAndStartServer(t *testing.T, conf httpConfig, ws bool, wsConf wsConfig) *httpServer {
t.Helper()