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

@@ -218,7 +218,7 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
rw.WriteHeader(res.StatusCode)
err = utils.CopyCloseWithContext(ctx, rw, res.Body)
err = utils.CopyCloseWithContext(ctx, rw, res.Body, int(res.ContentLength))
if err != nil {
if !errors.Is(err, context.Canceled) {
p.getErrorHandler()(rw, req, err)