优化代码

This commit is contained in:
刘祥超
2021-12-19 11:32:26 +08:00
parent 79ea9e795e
commit 8b97638624
14 changed files with 154 additions and 66 deletions

View File

@@ -194,13 +194,14 @@ func (this *HTTPRequest) doCacheRead(useStale bool) (shouldStop bool) {
}
// 准备Buffer
buf := bytePool32k.Get()
var pool = this.bytePool(reader.BodySize())
var buf = pool.Get()
defer func() {
bytePool32k.Put(buf)
pool.Put(buf)
}()
// 读取Header
headerBuf := []byte{}
var headerBuf = []byte{}
err = reader.ReadHeader(buf, func(n int) (goNext bool, err error) {
headerBuf = append(headerBuf, buf[:n]...)
for {