Files
EdgeNode/internal/nodes/http_request_error.go

33 lines
678 B
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)
msg := "404 page not found: '" + this.RawURI() + "'"
this.writer.WriteHeader(http.StatusNotFound)
_, _ = this.writer.Write([]byte(msg))
}
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)))
}