优化代码

This commit is contained in:
GoEdgeLab
2021-05-23 16:16:56 +08:00
parent 8526e7bad1
commit e33477d417
3 changed files with 30 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
package nodes
import (
"context"
"errors"
"fmt"
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
@@ -9,6 +10,7 @@ import (
"github.com/TeaOSLab/EdgeNode/internal/stats"
"github.com/TeaOSLab/EdgeNode/internal/utils"
"github.com/iwind/TeaGo/types"
"golang.org/x/net/http2"
"net"
"net/http"
"net/url"
@@ -1133,3 +1135,24 @@ func (this *HTTPRequest) bytePool(contentLength int64) *utils.BytePool {
}
return bytePool128k
}
// 检查是否可以忽略错误
func (this *HTTPRequest) canIgnore(err error) bool {
if err == nil {
return true
}
// 客户端主动取消
if err == context.Canceled {
return true
}
// HTTP/2流错误
{
_, ok := err.(http2.StreamError)
if ok {
return true
}
}
return false
}