diff --git a/client.go b/client.go index c26ec71..b9f4564 100644 --- a/client.go +++ b/client.go @@ -86,5 +86,6 @@ func (p *ClientUpgrader) UpgradeResponse(req *protocol.Request, resp *protocol.R conn.newCompressionWriter = compressNoContextTakeover conn.newDecompressionReader = decompressNoContextTakeover } + conn.resp = resp return conn, nil } diff --git a/conn.go b/conn.go index 2eb8874..3805bd0 100644 --- a/conn.go +++ b/conn.go @@ -282,6 +282,10 @@ type Conn struct { readDecompress bool // whether last read frame had RSV1 set newDecompressionReader func(io.Reader) io.ReadCloser + + // keep reference to the resp to make sure the underyling conn will not be closed. + // see: https://github.com/cloudwego/hertz/pull/1214 for the details. + resp interface{} // *protocol.Response } func newConn(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int, writeBufferPool BufferPool, br *bufio.Reader, writeBuf []byte) *Conn {