Skip to content

Commit

Permalink
websocket: fix compress flag bit(only set to 1 in first frame) in mul…
Browse files Browse the repository at this point in the history
…ti frames
  • Loading branch information
lesismal committed Sep 17, 2024
1 parent de9f897 commit afef10f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nbhttp/websocket/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit afef10f

Please sign in to comment.