diff --git a/httpbin/websocket/websocket.go b/httpbin/websocket/websocket.go index ebac941e..8a6643be 100644 --- a/httpbin/websocket/websocket.go +++ b/httpbin/websocket/websocket.go @@ -115,9 +115,6 @@ func (s *WebSocket) Handshake() error { panic("websocket: handshake already completed") } - if strings.ToLower(s.r.Header.Get("Connection")) != "upgrade" { - return fmt.Errorf("missing required `Connection: upgrade` header") - } if strings.ToLower(s.r.Header.Get("Upgrade")) != "websocket" { return fmt.Errorf("missing required `Upgrade: websocket` header") } diff --git a/httpbin/websocket/websocket_test.go b/httpbin/websocket/websocket_test.go index d6c02d10..6d848712 100644 --- a/httpbin/websocket/websocket_test.go +++ b/httpbin/websocket/websocket_test.go @@ -51,22 +51,22 @@ func TestHandshake(t *testing.T) { }, wantStatus: http.StatusSwitchingProtocols, }, - "missing Connection header": { + "missing Connection header is okay": { reqHeaders: map[string]string{ "Upgrade": "websocket", "Sec-WebSocket-Key": "dGhlIHNhbXBsZSBub25jZQ==", "Sec-WebSocket-Version": "13", }, - wantStatus: http.StatusBadRequest, + wantStatus: http.StatusSwitchingProtocols, }, - "incorrect Connection header": { + "incorrect Connection header is also okay": { reqHeaders: map[string]string{ - "Connection": "close", + "Connection": "foo", "Upgrade": "websocket", "Sec-WebSocket-Key": "dGhlIHNhbXBsZSBub25jZQ==", "Sec-WebSocket-Version": "13", }, - wantStatus: http.StatusBadRequest, + wantStatus: http.StatusSwitchingProtocols, }, "missing Upgrade header": { reqHeaders: map[string]string{