mirror of
https://github.com/mjl-/mox.git
synced 2025-06-28 11:38:16 +03:00
do not generate http status 502 for canceled http requests
do log them with level debug, and print the error in the http access log line.
This commit is contained in:
parent
f531a9bf35
commit
00ea31f2f6
@ -152,7 +152,11 @@ func (w *loggingWriter) Done() {
|
|||||||
tlsinfo = "(other)"
|
tlsinfo = "(other)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xlog.WithContext(w.R.Context()).Debugx("http request", w.WriteErr,
|
err := w.WriteErr
|
||||||
|
if err == nil {
|
||||||
|
err = w.R.Context().Err()
|
||||||
|
}
|
||||||
|
xlog.WithContext(w.R.Context()).Debugx("http request", err,
|
||||||
mlog.Field("httpaccess", ""),
|
mlog.Field("httpaccess", ""),
|
||||||
mlog.Field("handler", w.Handler),
|
mlog.Field("handler", w.Handler),
|
||||||
mlog.Field("method", method),
|
mlog.Field("method", method),
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package http
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
htmltemplate "html/template"
|
htmltemplate "html/template"
|
||||||
@ -415,6 +416,10 @@ func HandleForward(h *config.WebForward, w http.ResponseWriter, r *http.Request,
|
|||||||
proxy.FlushInterval = time.Duration(-1) // Flush after each write.
|
proxy.FlushInterval = time.Duration(-1) // Flush after each write.
|
||||||
proxy.ErrorLog = golog.New(mlog.ErrWriter(mlog.New("net/http/httputil").WithContext(r.Context()), mlog.LevelDebug, "reverseproxy error"), "", 0)
|
proxy.ErrorLog = golog.New(mlog.ErrWriter(mlog.New("net/http/httputil").WithContext(r.Context()), mlog.LevelDebug, "reverseproxy error"), "", 0)
|
||||||
proxy.ErrorHandler = func(w http.ResponseWriter, r *http.Request, err error) {
|
proxy.ErrorHandler = func(w http.ResponseWriter, r *http.Request, err error) {
|
||||||
|
if errors.Is(err, context.Canceled) {
|
||||||
|
log().Debugx("forwarding request to backend webserver", err, mlog.Field("url", r.URL))
|
||||||
|
return
|
||||||
|
}
|
||||||
log().Errorx("forwarding request to backend webserver", err, mlog.Field("url", r.URL))
|
log().Errorx("forwarding request to backend webserver", err, mlog.Field("url", r.URL))
|
||||||
if os.IsTimeout(err) {
|
if os.IsTimeout(err) {
|
||||||
http.Error(w, "504 - gateway timeout"+recvid(), http.StatusGatewayTimeout)
|
http.Error(w, "504 - gateway timeout"+recvid(), http.StatusGatewayTimeout)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user