mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 16:00:25 +08:00 
			
		
		
		
	请求源站错误时增加503、504错误
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
			
		||||
package nodes
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/iwind/TeaGo/types"
 | 
			
		||||
	"net/http"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -17,30 +18,15 @@ func (this *HTTPRequest) write404() {
 | 
			
		||||
	_, _ = this.writer.Write([]byte(msg))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *HTTPRequest) write500(err error) {
 | 
			
		||||
func (this *HTTPRequest) write50x(err error, statusCode int) {
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		this.addError(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	statusCode := http.StatusInternalServerError
 | 
			
		||||
	if this.doPage(statusCode) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	this.processResponseHeaders(statusCode)
 | 
			
		||||
	this.writer.WriteHeader(statusCode)
 | 
			
		||||
	_, _ = this.writer.Write([]byte(http.StatusText(statusCode)))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *HTTPRequest) write502(err error) {
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		this.addError(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	statusCode := http.StatusBadGateway
 | 
			
		||||
	if this.doPage(statusCode) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	this.processResponseHeaders(statusCode)
 | 
			
		||||
	this.writer.WriteHeader(statusCode)
 | 
			
		||||
	_, _ = this.writer.Write([]byte("502 Bad Gateway"))
 | 
			
		||||
	_, _ = this.writer.Write([]byte(types.String(statusCode) + " " + http.StatusText(statusCode)))
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user