make sure that Retry-After header has a value greater than zero

This commit is contained in:
Nicola Murino
2021-04-19 09:16:27 +02:00
parent f45c89fc46
commit 47317bed9b
3 changed files with 4 additions and 1 deletions

View File

@@ -160,6 +160,7 @@ func (s *webDavServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
delay, err := common.LimitRate(common.ProtocolWebDAV, ipAddr)
if err != nil {
delay += 499999999 * time.Nanosecond
w.Header().Set("Retry-After", fmt.Sprintf("%.0f", delay.Seconds()))
w.Header().Set("X-Retry-In", delay.String())
http.Error(w, err.Error(), http.StatusTooManyRequests)