在开发环境下打印Go语言内部HTTP调试信息

This commit is contained in:
刘祥超
2021-12-06 19:28:26 +08:00
parent 1bdb988425
commit 5b46c80431

View File

@@ -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协议