tweak: consolidate bytes pool management and enhance CopyClose functionality for improved performance

This commit is contained in:
yusing
2025-05-25 16:20:12 +08:00
parent b163771956
commit 8469b6406c
8 changed files with 86 additions and 37 deletions

View File

@@ -411,7 +411,7 @@ func (p *ReverseProxy) handler(rw http.ResponseWriter, req *http.Request) {
rw.WriteHeader(res.StatusCode)
err = U.CopyCloseWithContext(ctx, rw, res.Body) // close now, instead of defer, to populate res.Trailer
err = U.CopyCloseWithContext(ctx, rw, res.Body, int(res.ContentLength)) // close now, instead of defer, to populate res.Trailer
if err != nil {
if !errors.Is(err, context.Canceled) {
p.errorHandler(rw, req, err, false)