return 504 status for timeout errors

modify custom TimeoutHandler to return 504 error and switch imageproxy
to use that func.

Fixes #75
This commit is contained in:
Will Norris 2016-11-29 15:39:59 -08:00
parent e180185856
commit 576b7c023a
2 changed files with 4 additions and 3 deletions

View file

@ -18,7 +18,7 @@ import (
//
// The new Handler calls h.ServeHTTP to handle each request, but if a
// call runs for longer than its time limit, the handler responds with
// a 503 Service Unavailable error and the given message in its body.
// a 504 Gateway Timeout error and the given message in its body.
// (If msg is empty, a suitable default message will be sent.)
// After such a timeout, writes by h to its ResponseWriter will return
// ErrHandlerTimeout.
@ -89,7 +89,7 @@ func (h *timeoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
case <-timeout:
tw.mu.Lock()
defer tw.mu.Unlock()
w.WriteHeader(http.StatusServiceUnavailable)
w.WriteHeader(http.StatusGatewayTimeout)
io.WriteString(w, h.errorBody())
tw.timedOut = true
return