test: fix TestNormalizeWebsocketHeadersSurvivesCopyHeader assertion

http.Header.Get re-canonicalizes its argument via CanonicalHeaderKey,
so rebuilt.Get("Sec-WebSocket-Key") looks up the Go-canonical form
"Sec-Websocket-Key" — the key normalizeWebsocketHeaders just deleted.
Use a direct map lookup instead to assert the RFC 6455 key is present.
This commit is contained in:
SapirBaruch 2026-06-02 21:09:56 +03:00
parent 5e44b98a7b
commit 04c494cb00

View file

@ -97,8 +97,9 @@ func TestNormalizeWebsocketHeadersSurvivesCopyHeader(t *testing.T) {
// The fix: call normalizeWebsocketHeaders after the rebuild.
normalizeWebsocketHeaders(rebuilt)
// RFC 6455 form must be present.
if v := rebuilt.Get("Sec-WebSocket-Key"); v == "" {
// RFC 6455 form must be present (direct map lookup — .Get() re-canonicalizes
// to "Sec-Websocket-Key" and would miss the corrected key).
if _, ok := rebuilt["Sec-WebSocket-Key"]; !ok {
t.Error("Sec-WebSocket-Key missing after normalize; WebSocket upgrade will fail")
}
// Lowercase form must be gone.