MCPcopy
hub / github.com/coder/websocket / Read

Method Read

read.go:521–541  ·  view source on GitHub ↗
(p []byte)

Source from the content-addressed store, hash-verified

519}
520
521func (lr *limitReader) Read(p []byte) (int, error) {
522 if lr.n < 0 {
523 return lr.r.Read(p)
524 }
525
526 if lr.n == 0 {
527 reason := fmt.Errorf("read limited at %d bytes", lr.limit.Load())
528 lr.c.writeError(StatusMessageTooBig, reason)
529 return 0, fmt.Errorf("%w: %v", ErrMessageTooBig, reason)
530 }
531
532 if int64(len(p)) > lr.n {
533 p = p[:lr.n]
534 }
535 n, err := lr.r.Read(p)
536 lr.n -= int64(n)
537 if lr.n < 0 {
538 lr.n = 0
539 }
540 return n, err
541}

Callers

nothing calls this directly

Calls 2

writeErrorMethod · 0.80
ReadMethod · 0.45

Tested by

no test coverage detected