2020-09-26 08:07:07 +08:00
|
|
|
package nodes
|
|
|
|
|
|
|
|
|
|
import (
|
2021-09-01 08:48:03 +08:00
|
|
|
"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))
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-01 08:48:03 +08:00
|
|
|
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)
|
2021-09-01 08:48:03 +08:00
|
|
|
_, _ = this.writer.Write([]byte(types.String(statusCode) + " " + http.StatusText(statusCode)))
|
2020-11-30 20:57:16 +08:00
|
|
|
}
|