ReadChunk returns the next Chunk from the underlying channel with timestamps intact. Bytes are returned without being copied into a caller buffer; parsers that want chunk-level timestamps (e.g. HTTP/2 frame parsers that care about per-frame arrival time) use this instead of Read. ReadChunk returns
()
| 206 | // were drained from; callers should typically use Read XOR ReadChunk |
| 207 | // on a single FakeConn to avoid mixing the two. |
| 208 | func (f *FakeConn) ReadChunk() (Chunk, error) { |
| 209 | if f.closed.Load() { |
| 210 | // See Read: a chunk already delivered to f.ch (or stashed) is a |
| 211 | // recorded wire event and must survive Close. Drain what is |
| 212 | // buffered before reporting ErrClosed. |
| 213 | if c, ok := f.drainBufferedLocked(); ok { |
| 214 | return c, nil |
| 215 | } |
| 216 | return Chunk{}, ErrClosed |
| 217 | } |
| 218 | return f.readChunkLocked() |
| 219 | } |
| 220 | |
| 221 | // drainBufferedLocked returns the next chunk that is ALREADY available |
| 222 | // without blocking: first any residual bytes left in the internal stash |