-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Open
Labels
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
Description
len(buf) must equal to 0 for AvailableBuffer()
// AvailableBuffer returns an empty buffer with b.Available() capacity.
// This buffer is intended to be appended to and
// passed to an immediately succeeding [Writer.Write] call.
// The buffer is only valid until the next write operation on b.
func (b *Writer) AvailableBuffer() []byte {
return b.buf[b.n:][:0]
}
i think the len(buf) may switch to cap(buf) ?
https://github.com/gorilla/websocket/blob/main/server.go#L208
buf := brw.Writer.AvailableBuffer()
var writeBuf []byte
if u.WriteBufferPool == nil && u.WriteBufferSize == 0 && len(buf) >= maxFrameHeaderSize+256 {
// Reuse hijacked write buffer as connection buffer.
writeBuf = buf
}
i commit a fix pr: #972
Expected Behavior
No response
Steps To Reproduce
No response
Anything else?
No response