@@ -185,6 +185,14 @@ func Test_verifyClientHandshake(t *testing.T) {
185
185
},
186
186
{
187
187
name : "missingWebSocketKey" ,
188
+ h : map [string ]string {
189
+ "Connection" : "Upgrade" ,
190
+ "Upgrade" : "websocket" ,
191
+ "Sec-WebSocket-Version" : "13" ,
192
+ },
193
+ },
194
+ {
195
+ name : "emptyWebSocketKey" ,
188
196
h : map [string ]string {
189
197
"Connection" : "Upgrade" ,
190
198
"Upgrade" : "websocket" ,
@@ -210,6 +218,18 @@ func Test_verifyClientHandshake(t *testing.T) {
210
218
"Sec-WebSocket-Key" : "notbase64" ,
211
219
},
212
220
},
221
+ {
222
+ name : "extraWebSocketKey" ,
223
+ h : map [string ]string {
224
+ "Connection" : "Upgrade" ,
225
+ "Upgrade" : "websocket" ,
226
+ "Sec-WebSocket-Version" : "13" ,
227
+ // Kinda cheeky, but http headers are case-insensitive.
228
+ // If 2 sec keys are present, this is a failure condition.
229
+ "Sec-WebSocket-Key" : xrand .Base64 (16 ),
230
+ "sec-webSocket-key" : xrand .Base64 (16 ),
231
+ },
232
+ },
213
233
{
214
234
name : "badHTTPVersion" ,
215
235
h : map [string ]string {
@@ -256,7 +276,7 @@ func Test_verifyClientHandshake(t *testing.T) {
256
276
}
257
277
258
278
for k , v := range tc .h {
259
- r .Header .Set (k , v )
279
+ r .Header .Add (k , v )
260
280
}
261
281
262
282
_ , err := verifyClientRequest (httptest .NewRecorder (), r )
0 commit comments