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 (
17
17
"github.com/coder/websocket/internal/util"
18
18
)
19
19
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
+
20
28
// Reader reads from the connection until there is a WebSocket
21
29
// data message to be read. It will handle ping, pong and close frames as appropriate.
22
30
//
@@ -520,7 +528,7 @@ func (lr *limitReader) Read(p []byte) (int, error) {
520
528
}
521
529
522
530
if lr .n == 0 {
523
- err := fmt . Errorf ( "read limited at %v bytes" , lr .limit .Load ())
531
+ err := MessageTooBigError { Limit : lr .limit .Load ()}
524
532
lr .c .writeError (StatusMessageTooBig , err )
525
533
return 0 , err
526
534
}
You can’t perform that action at this time.
0 commit comments