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

View File

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