good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 454aee86 authored by Anmol Sethi's avatar Anmol Sethi
Browse files

ws_js.go: Disable read limit on -1

Whoops, updates #254 and closes #410
parent b4e4f4f1
No related branches found
No related tags found
No related merge requests found
......@@ -42,7 +42,7 @@ const (
// Conn provides a wrapper around the browser WebSocket API.
type Conn struct {
noCopy noCopy
ws wsjs.WebSocket
ws wsjs.WebSocket
// read limit for a message in bytes.
msgReadLimit xsync.Int64
......@@ -138,7 +138,8 @@ func (c *Conn) Read(ctx context.Context) (MessageType, []byte, error) {
if err != nil {
return 0, nil, fmt.Errorf("failed to read: %w", err)
}
if int64(len(p)) > c.msgReadLimit.Load() {
readLimit := c.msgReadLimit.Load()
if readLimit >= 0 && int64(len(p)) > readLimit {
err := fmt.Errorf("read limited at %v bytes", c.msgReadLimit.Load())
c.Close(StatusMessageTooBig, err.Error())
return 0, nil, err
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment