Make sure no content length is outputted in non-content circumstances.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Captain ALM 2022-07-15 15:25:50 +01:00
parent 3910d29fa2
commit 1a48e7815f
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1
1 changed files with 3 additions and 0 deletions

View File

@ -37,6 +37,7 @@ func ProcessSupportedPreconditionsForNext(rw http.ResponseWriter, req *http.Requ
}
if conditionFailed {
SwitchToNonCachingHeaders(rw.Header())
rw.Header().Del("Content-Length")
WriteResponseHeaderCanWriteBody(req.Method, rw, http.StatusPreconditionFailed, "")
return false
}
@ -54,6 +55,7 @@ func ProcessSupportedPreconditionsForNext(rw http.ResponseWriter, req *http.Requ
parse, err := time.Parse(http.TimeFormat, req.Header.Get("If-Unmodified-Since"))
if err == nil && modT.After(parse) {
SwitchToNonCachingHeaders(rw.Header())
rw.Header().Del("Content-Length")
WriteResponseHeaderCanWriteBody(req.Method, rw, http.StatusPreconditionFailed, "")
return false
}
@ -99,6 +101,7 @@ func ProcessRangePreconditions(maxLength int64, rw http.ResponseWriter, req *htt
}
} else {
SwitchToNonCachingHeaders(rw.Header())
rw.Header().Del("Content-Length")
rw.Header().Set("Content-Range", "bytes */"+strconv.FormatInt(maxLength, 10))
WriteResponseHeaderCanWriteBody(req.Method, rw, http.StatusRequestedRangeNotSatisfiable, "")
return nil