From d62fccf0a4cf911d778bddaad1a165f9d7ddf545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Mon, 3 Jan 2022 18:10:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E6=BA=90=E7=AB=99=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=9A=84=E5=86=85=E5=AE=B9=E9=95=BF=E5=BA=A6=E4=B8=BA?= =?UTF-8?q?0=EF=BC=8C=E5=88=99=E4=B8=8D=E5=86=8D=E5=B0=9D=E8=AF=95?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/http_client_pool.go | 3 +-- internal/nodes/http_request_reverse_proxy.go | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/nodes/http_client_pool.go b/internal/nodes/http_client_pool.go index 06cd64e..58d0839 100644 --- a/internal/nodes/http_client_pool.go +++ b/internal/nodes/http_client_pool.go @@ -84,7 +84,6 @@ func (this *HTTPClientPool) Client(req *HTTPRequest, origin *serverconfigs.Origi if idleConns <= 0 { idleConns = numberCPU * 8 } - //logs.Println("[ORIGIN]max connections:", maxConnections) // TLS通讯 tlsConfig := &tls.Config{ @@ -101,7 +100,7 @@ func (this *HTTPClientPool) Client(req *HTTPRequest, origin *serverconfigs.Origi } } - transport := &http.Transport{ + var transport = &http.Transport{ DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { // 支持TOA的连接 toaConfig := sharedTOAManager.Config() diff --git a/internal/nodes/http_request_reverse_proxy.go b/internal/nodes/http_request_reverse_proxy.go index 4aeef68..e545df0 100644 --- a/internal/nodes/http_request_reverse_proxy.go +++ b/internal/nodes/http_request_reverse_proxy.go @@ -293,6 +293,13 @@ func (this *HTTPRequest) doReverseProxy() { this.writer.WriteHeader(resp.StatusCode) } + // 是否有内容 + if resp.ContentLength == 0 && len(resp.TransferEncoding) == 0 { + _ = resp.Body.Close() + this.writer.SetOk() + return + } + // 输出到客户端 pool := this.bytePool(resp.ContentLength) buf := pool.Get()