mirror of
https://github.com/caddyserver/caddy.git
synced 2026-07-10 19:04:22 +00:00
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:
parent
5e44b98a7b
commit
04c494cb00
1 changed files with 3 additions and 2 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue