mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-13 06:50:25 +08:00
优化代码
This commit is contained in:
@@ -315,7 +315,7 @@ func (this *HTTPRequest) doOriginRequest(failedOriginIds []int64, failedLnNodeId
|
|||||||
if requestErr != nil {
|
if requestErr != nil {
|
||||||
// 客户端取消请求,则不提示
|
// 客户端取消请求,则不提示
|
||||||
var httpErr *url.Error
|
var httpErr *url.Error
|
||||||
ok := errors.As(requestErr, &httpErr)
|
var ok = errors.As(requestErr, &httpErr)
|
||||||
if !ok {
|
if !ok {
|
||||||
if isHTTPOrigin {
|
if isHTTPOrigin {
|
||||||
SharedOriginStateManager.Fail(origin, requestHost, this.reverseProxy, func() {
|
SharedOriginStateManager.Fail(origin, requestHost, this.reverseProxy, func() {
|
||||||
@@ -361,7 +361,6 @@ func (this *HTTPRequest) doOriginRequest(failedOriginIds []int64, failedLnNodeId
|
|||||||
} else {
|
} else {
|
||||||
// 是否为客户端方面的错误
|
// 是否为客户端方面的错误
|
||||||
var isClientError = false
|
var isClientError = false
|
||||||
if ok {
|
|
||||||
if errors.Is(httpErr, context.Canceled) {
|
if errors.Is(httpErr, context.Canceled) {
|
||||||
// 如果是服务器端主动关闭,则无需提示
|
// 如果是服务器端主动关闭,则无需提示
|
||||||
if this.isConnClosed() {
|
if this.isConnClosed() {
|
||||||
@@ -373,7 +372,6 @@ func (this *HTTPRequest) doOriginRequest(failedOriginIds []int64, failedLnNodeId
|
|||||||
this.addError(errors.New(httpErr.Op + " " + httpErr.URL + ": client closed the connection"))
|
this.addError(errors.New(httpErr.Op + " " + httpErr.URL + ": client closed the connection"))
|
||||||
this.writer.WriteHeader(499) // 仿照nginx
|
this.writer.WriteHeader(499) // 仿照nginx
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if !isClientError {
|
if !isClientError {
|
||||||
this.write50x(requestErr, http.StatusBadGateway, "Failed to read origin site", "源站读取失败", true)
|
this.write50x(requestErr, http.StatusBadGateway, "Failed to read origin site", "源站读取失败", true)
|
||||||
|
|||||||
Reference in New Issue
Block a user