请求源站错误时增加503、504错误

This commit is contained in:
GoEdgeLab
2021-09-01 08:48:03 +08:00
parent 4c15103717
commit 7b4d9d8cc0
8 changed files with 35 additions and 42 deletions

View File

@@ -2,7 +2,6 @@ package nodes
import (
"errors"
"github.com/iwind/TeaGo/logs"
"io"
"net/http"
"net/url"
@@ -43,8 +42,7 @@ func (this *HTTPRequest) doWebsocket() {
// TODO 增加N次错误重试重试的时候需要尝试不同的源站
originConn, err := OriginConnect(this.origin, this.RawReq.RemoteAddr)
if err != nil {
logs.Error(err)
this.write500(err)
this.write50x(err, http.StatusBadGateway)
return
}
defer func() {
@@ -53,15 +51,13 @@ func (this *HTTPRequest) doWebsocket() {
err = this.RawReq.Write(originConn)
if err != nil {
logs.Error(err)
this.write500(err)
this.write50x(err, http.StatusBadGateway)
return
}
clientConn, _, err := this.writer.Hijack()
if err != nil {
logs.Error(err)
this.write500(err)
this.write50x(err, http.StatusInternalServerError)
return
}
defer func() {