File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,14 @@ import (
1717 "github.com/coder/websocket/internal/util"
1818)
1919
20+ type MessageTooBigError struct {
21+ Limit int64
22+ }
23+
24+ func (e MessageTooBigError ) Error () string {
25+ return fmt .Sprintf ("read limited at %v bytes" , e .Limit )
26+ }
27+
2028// Reader reads from the connection until there is a WebSocket
2129// data message to be read. It will handle ping, pong and close frames as appropriate.
2230//
@@ -520,7 +528,7 @@ func (lr *limitReader) Read(p []byte) (int, error) {
520528 }
521529
522530 if lr .n == 0 {
523- err := fmt . Errorf ( "read limited at %v bytes" , lr .limit .Load ())
531+ err := MessageTooBigError { Limit : lr .limit .Load ()}
524532 lr .c .writeError (StatusMessageTooBig , err )
525533 return 0 , err
526534 }
You can’t perform that action at this time.
0 commit comments