You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Websocket's Read() method returns os.E2BIG if the message doesn't fit
the buffer. The JSON decoder doesn't handle this and returns the error
to the caller.
I'm currently working around this with:
--- a/src/pkg/json/stream.go Mon Sep 27 11:42:58 2010 +1000
+++ b/src/pkg/json/stream.go Mon Sep 27 10:25:10 2010 +0300
@@ -107,7 +107,17 @@
// Read. Delay error for next iteration (after scan).
var n int
- n, err = dec.r.Read(dec.buf[len(dec.buf):cap(dec.buf)])
+ for {
+ n, err = dec.r.Read(dec.buf[len(dec.buf):cap(dec.buf)])
+ if err == os.E2BIG {
+ newBuf := make([]byte, len(dec.buf), 2*cap(dec.buf)+minRead)
+ copy(newBuf, dec.buf)
+ dec.buf = newBuf
+ continue
+ }
+ break
+ }
+
dec.buf = dec.buf[0 : len(dec.buf)+n]
}
return scanp, nil
The text was updated successfully, but these errors were encountered:
The bug is that websocket's Read should be able to handle
reading a fragment of a frame. It should remember that
there is more data coming and return that data to the next Read.
by joamaki:
The text was updated successfully, but these errors were encountered: