accumulateReadLocked updates the buffer, byte counters, and truncation/EOF flags after a read. The caller must hold r.mu.
(data []byte, n int, err error)
| 232 | // accumulateReadLocked updates the buffer, byte counters, and |
| 233 | // truncation/EOF flags after a read. The caller must hold r.mu. |
| 234 | func (r *recordingBody) accumulateReadLocked(data []byte, n int, err error) { |
| 235 | r.bytesRead += int64(n) |
| 236 | if n > 0 && !r.truncated { |
| 237 | remaining := maxRecordedResponseBodyBytes - r.buf.Len() |
| 238 | if remaining > 0 { |
| 239 | toWrite := n |
| 240 | if toWrite > remaining { |
| 241 | toWrite = remaining |
| 242 | r.truncated = true |
| 243 | } |
| 244 | _, _ = r.buf.Write(data[:toWrite]) |
| 245 | } else { |
| 246 | r.truncated = true |
| 247 | } |
| 248 | } |
| 249 | if errors.Is(err, io.EOF) { |
| 250 | r.sawEOF = true |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | func (r *recordingBody) Read(p []byte) (int, error) { |
| 255 | n, err := r.inner.Read(p) |
no test coverage detected