From afef10f44834679db278264093cd858d87de9550 Mon Sep 17 00:00:00 2001 From: lesismal Date: Tue, 17 Sep 2024 20:32:19 +0800 Subject: [PATCH] websocket: fix compress flag bit(only set to 1 in first frame) in multi frames --- nbhttp/websocket/conn.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nbhttp/websocket/conn.go b/nbhttp/websocket/conn.go index f27f473f..8c3f50da 100644 --- a/nbhttp/websocket/conn.go +++ b/nbhttp/websocket/conn.go @@ -583,22 +583,23 @@ func (c *Conn) WriteMessage(messageType MessageType, data []byte) error { } else { cw.Close() data = w.Bytes() - return c.writeFrame(messageType, true, true, data, true) } } if len(data) > 0 { sendOpcode := true + sendCompress := compress for len(data) > 0 { n := len(data) if n > c.Engine.MaxWebsocketFramePayloadSize { n = c.Engine.MaxWebsocketFramePayloadSize } - err := c.writeFrame(messageType, sendOpcode, n == len(data), data[:n], compress) + err := c.writeFrame(messageType, sendOpcode, n == len(data), data[:n], sendCompress) if err != nil { return err } sendOpcode = false + sendCompress = false data = data[n:] } return nil