We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bac4153 commit a1b12a2Copy full SHA for a1b12a2
websocket.go
@@ -501,6 +501,14 @@ func (r *MessageReader) SetContext(ctx context.Context) {
501
}
502
503
// Limit limits the number of bytes read by the reader.
504
+//
505
+// Why not use io.LimitReader? io.LimitReader returns a io.EOF
506
+// after the limit bytes which means its not possible to tell
507
+// whether the message has been read or a limit has been hit.
508
+// This results in unclear error and log messages.
509
+// This function will cause the connection to be closed if the limit is hit
510
+// with a close reason explaining the error and also an error
511
+// indicating the limit was hit.
512
func (r *MessageReader) Limit(bytes int) {
513
r.limit = bytes
514
0 commit comments