From 8690157240d47ef5cecd909ba57462d90849d665 Mon Sep 17 00:00:00 2001 From: WeidiDeng Date: Fri, 18 Apr 2025 08:21:55 +0800 Subject: [PATCH] set read/write buffer and enable nagle's algorithm for testing --- modules/caddyhttp/reverseproxy/httptransport.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/caddyhttp/reverseproxy/httptransport.go b/modules/caddyhttp/reverseproxy/httptransport.go index 92fe9ab7c..52e0f1629 100644 --- a/modules/caddyhttp/reverseproxy/httptransport.go +++ b/modules/caddyhttp/reverseproxy/httptransport.go @@ -276,6 +276,18 @@ func (h *HTTPTransport) NewTransport(caddyCtx caddy.Context) (*http.Transport, e return nil, DialError{err} } + // set read/write buffer, enable nagle's algorithm + if srb, ok := conn.(interface{ SetReadBuffer(int) error }); ok { + _ = srb.SetReadBuffer(4096) + + } + if swb, ok := conn.(interface{ SetWriteBuffer(int) error }); ok { + _ = swb.SetWriteBuffer(4096) + } + if snd, ok := conn.(interface{ SetNoDelay(bool) error }); ok { + _ = snd.SetNoDelay(false) + } + if h.ProxyProtocol != "" { proxyProtocolInfo, ok := caddyhttp.GetVar(ctx, proxyProtocolInfoVarKey).(ProxyProtocolInfo) if !ok {