Files
EdgeNode/internal/nodes/http_request_error.go

40 lines
1.0 KiB
Go
Raw Normal View History

2020-09-26 08:07:07 +08:00
package nodes
import (
"github.com/iwind/TeaGo/types"
2020-09-26 08:07:07 +08:00
"net/http"
)
2020-09-26 11:22:21 +08:00
func (this *HTTPRequest) write404() {
2020-09-26 08:07:07 +08:00
if this.doPage(http.StatusNotFound) {
return
}
this.processResponseHeaders(http.StatusNotFound)
this.writer.WriteHeader(http.StatusNotFound)
_, _ = this.writer.Write([]byte("404 page not found: '" + this.requestFullURL() + "'" + " (Request Id: " + this.requestId + ")"))
2020-09-26 08:07:07 +08:00
}
2021-12-12 11:48:01 +08:00
func (this *HTTPRequest) writeCode(code int) {
if this.doPage(code) {
return
}
this.processResponseHeaders(code)
this.writer.WriteHeader(code)
_, _ = this.writer.Write([]byte(types.String(code) + " " + http.StatusText(code) + ": '" + this.requestFullURL() + "'" + " (Request Id: " + this.requestId + ")"))
}
func (this *HTTPRequest) write50x(err error, statusCode int) {
2020-09-27 15:26:06 +08:00
if err != nil {
this.addError(err)
}
2020-09-26 08:07:07 +08:00
if this.doPage(statusCode) {
return
}
this.processResponseHeaders(statusCode)
this.writer.WriteHeader(statusCode)
_, _ = this.writer.Write([]byte(types.String(statusCode) + " " + http.StatusText(statusCode) + " (Request Id: " + this.requestId + ")"))
}