@@ -1141,14 +1141,13 @@ func TestAutobahn(t *testing.T) {
1141
1141
err := c .PingWithPayload (ctx , string (p ))
1142
1142
return assertCloseStatus (err , websocket .StatusProtocolError )
1143
1143
})
1144
- // See comment on the tenStreamedPings test.
1145
- // run(t, "streamPingPayload", func(ctx context.Context, c *websocket.Conn) error {
1146
- // err := assertStreamPing(ctx, c, 125)
1147
- // if err != nil {
1148
- // return err
1149
- // }
1150
- // return c.Close(websocket.StatusNormalClosure, "")
1151
- // })
1144
+ run (t , "streamPingPayload" , func (ctx context.Context , c * websocket.Conn ) error {
1145
+ err := assertStreamPing (ctx , c , 125 )
1146
+ if err != nil {
1147
+ return err
1148
+ }
1149
+ return c .Close (websocket .StatusNormalClosure , "" )
1150
+ })
1152
1151
t .Run ("unsolicitedPong" , func (t * testing.T ) {
1153
1152
t .Parallel ()
1154
1153
@@ -1212,18 +1211,16 @@ func TestAutobahn(t *testing.T) {
1212
1211
return assertCloseStatus (err , websocket .StatusNormalClosure )
1213
1212
})
1214
1213
1215
- // Streamed pings tests are not useful with this implementation since we always
1216
- // use io.ReadFull. These tests cause failures when running with -race on my mac.
1217
- // run(t, "tenStreamedPings", func(ctx context.Context, c *websocket.Conn) error {
1218
- // for i := 0; i < 10; i++ {
1219
- // err := assertStreamPing(ctx, c, 125)
1220
- // if err != nil {
1221
- // return err
1222
- // }
1223
- // }
1224
- //
1225
- // return c.Close(websocket.StatusNormalClosure, "")
1226
- // })
1214
+ run (t , "tenStreamedPings" , func (ctx context.Context , c * websocket.Conn ) error {
1215
+ for i := 0 ; i < 10 ; i ++ {
1216
+ err := assertStreamPing (ctx , c , 125 )
1217
+ if err != nil {
1218
+ return err
1219
+ }
1220
+ }
1221
+
1222
+ return c .Close (websocket .StatusNormalClosure , "" )
1223
+ })
1227
1224
})
1228
1225
1229
1226
// Section 3.
@@ -1964,11 +1961,17 @@ func assertStreamPing(ctx context.Context, c *websocket.Conn, l int) error {
1964
1961
if err != nil {
1965
1962
return fmt .Errorf ("failed to write byte %d: %w" , i , err )
1966
1963
}
1967
- err = c .BW ().Flush ()
1968
- if err != nil {
1969
- return fmt .Errorf ("failed to flush byte %d: %w" , i , err )
1964
+ if i % 32 == 0 {
1965
+ err = c .BW ().Flush ()
1966
+ if err != nil {
1967
+ return fmt .Errorf ("failed to flush at byte %d: %w" , i , err )
1968
+ }
1970
1969
}
1971
1970
}
1971
+ err = c .BW ().Flush ()
1972
+ if err != nil {
1973
+ return fmt .Errorf ("failed to flush: %v" , err )
1974
+ }
1972
1975
return assertReadFrame (ctx , c , websocket .OpPong , bytes .Repeat ([]byte {0xFE }, l ))
1973
1976
}
1974
1977
0 commit comments