不再提示http2 Stream相关错误

This commit is contained in:
刘祥超
2021-05-23 15:50:21 +08:00
parent 9545bf69db
commit df5f50682a
2 changed files with 24 additions and 8 deletions

View File

@@ -6,6 +6,7 @@ import (
"github.com/TeaOSLab/EdgeNode/internal/caches" "github.com/TeaOSLab/EdgeNode/internal/caches"
"github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/remotelogs"
"github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/logs"
"golang.org/x/net/http2"
"net/http" "net/http"
"strconv" "strconv"
) )
@@ -89,7 +90,9 @@ func (this *HTTPRequest) doCacheRead() (shouldStop bool) {
return return
} }
if _, ok := err.(http2.StreamError); !ok {
remotelogs.Error("REQUEST_CACHE", "read from cache failed: "+err.Error()) remotelogs.Error("REQUEST_CACHE", "read from cache failed: "+err.Error())
}
return return
} }
defer func() { defer func() {
@@ -121,7 +124,9 @@ func (this *HTTPRequest) doCacheRead() (shouldStop bool) {
return true, nil return true, nil
}) })
if err != nil { if err != nil {
if _, ok := err.(http2.StreamError); !ok {
remotelogs.Error("REQUEST_CACHE", "read from cache failed: "+err.Error()) remotelogs.Error("REQUEST_CACHE", "read from cache failed: "+err.Error())
}
return return
} }
@@ -211,7 +216,9 @@ func (this *HTTPRequest) doCacheRead() (shouldStop bool) {
this.writer.WriteHeader(http.StatusRequestedRangeNotSatisfiable) this.writer.WriteHeader(http.StatusRequestedRangeNotSatisfiable)
return true return true
} }
if _, ok := err.(http2.StreamError); !ok {
remotelogs.Error("REQUEST_CACHE", "read from cache failed: "+err.Error()) remotelogs.Error("REQUEST_CACHE", "read from cache failed: "+err.Error())
}
return return
} }
} else if len(rangeSet) > 1 { } else if len(rangeSet) > 1 {
@@ -252,7 +259,9 @@ func (this *HTTPRequest) doCacheRead() (shouldStop bool) {
return true, err return true, err
}) })
if err != nil { if err != nil {
if _, ok := err.(http2.StreamError); !ok {
remotelogs.Error("REQUEST_CACHE", "read from cache failed: "+err.Error()) remotelogs.Error("REQUEST_CACHE", "read from cache failed: "+err.Error())
}
return true return true
} }
} }
@@ -273,7 +282,9 @@ func (this *HTTPRequest) doCacheRead() (shouldStop bool) {
return true, nil return true, nil
}) })
if err != nil { if err != nil {
if _, ok := err.(http2.StreamError); !ok {
remotelogs.Error("REQUEST_CACHE", "read from cache failed: "+err.Error()) remotelogs.Error("REQUEST_CACHE", "read from cache failed: "+err.Error())
}
return return
} }
} }

View File

@@ -7,6 +7,7 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
"github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/remotelogs"
"github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils"
"golang.org/x/net/http2"
"io" "io"
"net/url" "net/url"
"strconv" "strconv"
@@ -256,11 +257,15 @@ func (this *HTTPRequest) doReverseProxy() {
err1 := resp.Body.Close() err1 := resp.Body.Close()
if err1 != nil { if err1 != nil {
if _, ok := err1.(http2.StreamError); !ok {
remotelogs.Error("REQUEST_REVERSE_PROXY", err1.Error()) remotelogs.Error("REQUEST_REVERSE_PROXY", err1.Error())
} }
}
if err != nil && err != io.EOF { if err != nil && err != io.EOF {
if _, ok := err.(http2.StreamError); !ok {
remotelogs.Error("REQUEST_REVERSE_PROXY", err.Error()) remotelogs.Error("REQUEST_REVERSE_PROXY", err.Error())
this.addError(err) this.addError(err)
} }
}
} }