(p []byte)
| 519 | } |
| 520 | |
| 521 | func (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 | } |
nothing calls this directly
no test coverage detected