Comments

When using io.Copy() with a websocket as source, this fails if incoming websocket frames
are too large.
The reason is because io.Copy() uses a buffer with a default size for the Read().
websocket.Read() in turn uses bufio.ReadSlice() to read the current frame up to the
final 0xff. But if the incoming websocket frame size exceeds the buffer size of
io.Copy(), a ErrBufferFull ("bufio: buffer full") is generated.
The websocket specification does not limit the size of a frame, so this behaviour is
somewhat undesirable, as the success of a io.Copy() depends on the size of internal
buffers and the undeterminable websocket frame size.
What steps will reproduce the problem?
1. One process needs to open a websocket connection to a Go websocket server (pseudo
code, obviously):
ws := websocket.Dial("127.0.0.1:80")
buf := make([]byte, 100000)
ws.Write(buf)
2. Websocket server:
ws := accepted websocket.Conn
writer := io.Writer
err := io.Copy(writer, ws)
What is the expected output?
err == nil
What do you see instead?
err == bufio.ErrBufferFull
Which revision are you using? (hg identify)
1b38d90eebcd+ (release-branch.r58) tip
(patches applied at other locations)