good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 3233cb5a authored by Steven Masley's avatar Steven Masley Committed by Anmol Sethi
Browse files

Remove all leading and trailing whitespace

parent f46da9af
Branches
Tags
No related merge requests found
//go:build !js
// +build !js
package websocket
......@@ -185,6 +186,8 @@ func verifyClientRequest(w http.ResponseWriter, r *http.Request) (errCode int, _
}
websocketSecKey := r.Header.Get("Sec-WebSocket-Key")
// The RFC states to remove any leading or trailing whitespace.
websocketSecKey = strings.TrimSpace(websocketSecKey)
if websocketSecKey == "" {
return http.StatusBadRequest, errors.New("WebSocket protocol violation: missing Sec-WebSocket-Key")
}
......
//go:build !js
// +build !js
package websocket
......@@ -229,6 +230,16 @@ func Test_verifyClientHandshake(t *testing.T) {
},
success: true,
},
{
name: "successSecKeyExtraSpace",
h: map[string]string{
"Connection": "keep-alive, Upgrade",
"Upgrade": "websocket",
"Sec-WebSocket-Version": "13",
"Sec-WebSocket-Key": " " + xrand.Base64(16) + " ",
},
success: true,
},
}
for _, tc := range testCases {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment