From b220b0f48eab0d52a2205d23a1645e0847143774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Thu, 5 Jan 2023 00:40:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=BB=E5=8F=96HTTP?= =?UTF-8?q?=E8=AF=B7=E6=B1=82Header=E5=92=8C=E6=8F=A1=E6=89=8B=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/client_conn.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/nodes/client_conn.go b/internal/nodes/client_conn.go index 6afede6..7b32053 100644 --- a/internal/nodes/client_conn.go +++ b/internal/nodes/client_conn.go @@ -42,6 +42,7 @@ type ClientConn struct { lastErr error readDeadlineTime int64 + isShortReading bool // header or handshake } func NewClientConn(rawConn net.Conn, isHTTP bool, isTLS bool, isInAllowList bool) net.Conn { @@ -92,7 +93,7 @@ func (this *ClientConn) Read(b []byte) (n int, err error) { } // 设置读超时时间 - if this.isHTTP { + if this.isHTTP && !this.isShortReading { this.setHTTPReadTimeout() } @@ -211,6 +212,8 @@ func (this *ClientConn) SetDeadline(t time.Time) error { func (this *ClientConn) SetReadDeadline(t time.Time) error { if this.isHTTP { + this.isShortReading = false + var unixTime = t.Unix() if unixTime < 10 { return nil @@ -219,6 +222,9 @@ func (this *ClientConn) SetReadDeadline(t time.Time) error { return nil } this.readDeadlineTime = unixTime + if -time.Since(t) < HTTPIdleTimeout-1*time.Second { + this.isShortReading = true + } } return this.rawConn.SetReadDeadline(t) }