(p []byte)
| 44 | } |
| 45 | |
| 46 | func (s *streamingBodyDumper) Read(p []byte) (int, error) { |
| 47 | n, err := s.body.Read(p) |
| 48 | if n > 0 { |
| 49 | s.init() |
| 50 | if s.initErr != nil && s.logger != nil { |
| 51 | s.logger(s.initErr) |
| 52 | } |
| 53 | if s.file != nil { |
| 54 | // Write raw bytes as they stream through. |
| 55 | _, _ = s.file.Write(p[:n]) |
| 56 | } |
| 57 | } |
| 58 | return n, err |
| 59 | } |
| 60 | |
| 61 | func (s *streamingBodyDumper) Close() error { |
| 62 | // Ensure init() has completed to avoid racing with Read(). |