优化代码

This commit is contained in:
GoEdgeLab
2021-12-19 11:32:26 +08:00
parent b2fd11f8f4
commit 3ab0f64b18
14 changed files with 154 additions and 66 deletions
+4 -3
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 {