We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 91013c1 commit e96e02aCopy full SHA for e96e02a
1 file changed
read.go
@@ -17,6 +17,14 @@ import (
17
"github.com/coder/websocket/internal/util"
18
)
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
28
// Reader reads from the connection until there is a WebSocket
29
// data message to be read. It will handle ping, pong and close frames as appropriate.
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
0 commit comments