Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion read.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ import (
"github.com/coder/websocket/internal/util"
)

type MessageTooBigError struct {
Limit int64
}

func (e MessageTooBigError) Error() string {
return fmt.Sprintf("read limited at %v bytes", e.Limit)
}

// Reader reads from the connection until there is a WebSocket
// data message to be read. It will handle ping, pong and close frames as appropriate.
//
Expand Down Expand Up @@ -520,7 +528,7 @@ func (lr *limitReader) Read(p []byte) (int, error) {
}

if lr.n == 0 {
err := fmt.Errorf("read limited at %v bytes", lr.limit.Load())
err := MessageTooBigError{Limit: lr.limit.Load()}
lr.c.writeError(StatusMessageTooBig, err)
return 0, err
}
Expand Down