@@ -215,26 +215,37 @@ func TestOneWayWebSocket(t *testing.T) {
215
215
t .Run ("Produces an error if the socket connection could not be established" , func (t * testing.T ) {
216
216
t .Parallel ()
217
217
218
- // WebSocket connections cannot be created on HTTP/1.0 and below
219
- req := createBaseRequest (t )
220
- req .ProtoMajor = 1
221
- req .ProtoMinor = 0
222
- req .Proto = "HTTP/1.0"
223
-
224
- _ , _ , err := httpapi .OneWayWebSocket [any ](httptest .NewRecorder (), req )
225
- require .ErrorContains (
226
- t ,
227
- err ,
228
- "WebSocket protocol violation: handshake request must be at least HTTP/1.1:" ,
229
- )
218
+ incorrectProtocols := []struct {
219
+ major int
220
+ minor int
221
+ proto string
222
+ }{
223
+ {0 , 9 , "HTTP/0.9" },
224
+ {1 , 0 , "HTTP/1.0" },
225
+ }
226
+ for _ , p := range incorrectProtocols {
227
+ req := createBaseRequest (t )
228
+ req .ProtoMajor = p .major
229
+ req .ProtoMinor = p .minor
230
+ req .Proto = p .proto
231
+
232
+ _ , _ , err := httpapi .OneWayWebSocket [any ](httptest .NewRecorder (), req )
233
+ require .ErrorContains (
234
+ t ,
235
+ err ,
236
+ fmt .Sprintf (
237
+ "WebSocket protocol violation: handshake request must be at least HTTP/1.1: %q" ,
238
+ p .proto ,
239
+ ),
240
+ )
241
+ }
230
242
})
231
243
232
244
t .Run ("Returned callback can publish a new event to the WebSocket connection" , func (t * testing.T ) {
233
245
t .Parallel ()
234
246
235
- r := strings .NewReader ("" )
236
247
recorder := httptest .NewRecorder ()
237
- writer := wrapWriter (recorder , r )
248
+ writer := wrapWriter (recorder , strings . NewReader ( "" ) )
238
249
send , _ , err := httpapi .OneWayWebSocket [codersdk.ServerSentEvent ](
239
250
writer ,
240
251
createBaseRequest (t ),
0 commit comments