From 5b46c8043167a9b3454e9cb29e7beabcc4882d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Mon, 6 Dec 2021 19:28:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E5=BC=80=E5=8F=91=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E4=B8=8B=E6=89=93=E5=8D=B0Go=E8=AF=AD=E8=A8=80=E5=86=85?= =?UTF-8?q?=E9=83=A8HTTP=E8=B0=83=E8=AF=95=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/listener_http.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/nodes/listener_http.go b/internal/nodes/listener_http.go index 2791eb5..d4221bb 100644 --- a/internal/nodes/listener_http.go +++ b/internal/nodes/listener_http.go @@ -5,6 +5,7 @@ import ( "crypto/tls" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" + "github.com/iwind/TeaGo/Tea" "golang.org/x/net/http2" "io" "log" @@ -47,7 +48,6 @@ func (this *HTTPListener) Serve() error { Handler: this, ReadHeaderTimeout: 2 * time.Second, // TODO 改成可以配置 IdleTimeout: 2 * time.Minute, // TODO 改成可以配置 - ErrorLog: httpErrorLogger, ConnState: func(conn net.Conn, state http.ConnState) { switch state { case http.StateNew: @@ -76,6 +76,11 @@ func (this *HTTPListener) Serve() error { return context.WithValue(ctx, HTTPConnContextKey, c) }, } + + if !Tea.IsTesting() { + this.httpServer.ErrorLog = httpErrorLogger + } + this.httpServer.SetKeepAlivesEnabled(true) // HTTP协议