| 61 | } |
| 62 | |
| 63 | func (zc *zeroResponseConn) Read(b []byte) (n int, err error) { |
| 64 | n, err = zc.Conn.Read(b) |
| 65 | if err != nil && errors.Is(err, os.ErrDeadlineExceeded) { |
| 66 | zc.lastReadErrIsDeadlineExceeded.Store(true) |
| 67 | } else { |
| 68 | zc.lastReadErrIsDeadlineExceeded.Store(false) |
| 69 | } |
| 70 | |
| 71 | // Store first requestBufSize read bytes on connection into the buffer for logging. |
| 72 | if n > 0 { |
| 73 | zc.bufHolderMux.Lock() |
| 74 | defer zc.bufHolderMux.Unlock() |
| 75 | |
| 76 | if zc.bufHolder != nil { |
| 77 | rem := requestBufSize - len(zc.bufHolder.buf) // how much space is in our buffer. |
| 78 | if rem > n { |
| 79 | rem = n |
| 80 | } |
| 81 | if rem > 0 { |
| 82 | zc.bufHolder.buf = append(zc.bufHolder.buf, b[:rem]...) |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | return |
| 87 | } |
| 88 | |
| 89 | func (zc *zeroResponseConn) Write(b []byte) (n int, err error) { |
| 90 | n, err = zc.Conn.Write(b) |