fix boundary value bug when objTime ends in whole seconds (without sub-second) (#21419)

This commit is contained in:
MagicPig 2025-07-23 20:36:06 +08:00 committed by GitHub
parent 64f5c6103f
commit 50fcf9b670
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -331,7 +331,7 @@ func checkPreconditions(ctx context.Context, w http.ResponseWriter, r *http.Requ
func ifModifiedSince(objTime time.Time, givenTime time.Time) bool {
// The Date-Modified header truncates sub-second precision, so
// use mtime < t+1s instead of mtime <= t to check for unmodified.
return objTime.After(givenTime.Add(1 * time.Second))
return !objTime.Before(givenTime.Add(1 * time.Second))
}
// canonicalizeETag returns ETag with leading and trailing double-quotes removed,