优化字节缓冲区相关代码

This commit is contained in:
刘祥超
2024-04-15 09:26:00 +08:00
parent 4bdd248f99
commit 5e7ea9a884
15 changed files with 243 additions and 57 deletions

View File

@@ -70,11 +70,11 @@ func (this *HTTPRequest) doURL(method string, url string, host string, statusCod
var pool = this.bytePool(resp.ContentLength)
var buf = pool.Get()
if supportVariables {
_, err = utils.CopyWithFilter(this.writer, resp.Body, buf, func(p []byte) []byte {
_, err = utils.CopyWithFilter(this.writer, resp.Body, buf.Bytes, func(p []byte) []byte {
return []byte(this.Format(string(p)))
})
} else {
_, err = io.CopyBuffer(this.writer, resp.Body, buf)
_, err = io.CopyBuffer(this.writer, resp.Body, buf.Bytes)
}
pool.Put(buf)