Browse Source

fix: s3tests test_get_object_ifnonematch_good (#5237)

pull/5239/head
Konstantin Lebedev 11 months ago
committed by GitHub
parent
commit
0b71fae2e3
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      weed/server/filer_server_handlers_read.go

4
weed/server/filer_server_handlers_read.go

@ -67,12 +67,14 @@ func checkPreconditions(w http.ResponseWriter, r *http.Request, entry *filer.Ent
ifModifiedSinceHeader := r.Header.Get("If-Modified-Since") ifModifiedSinceHeader := r.Header.Get("If-Modified-Since")
if ifNoneMatchETagHeader != "" { if ifNoneMatchETagHeader != "" {
if util.CanonicalizeETag(etag) == util.CanonicalizeETag(ifNoneMatchETagHeader) { if util.CanonicalizeETag(etag) == util.CanonicalizeETag(ifNoneMatchETagHeader) {
setEtag(w, etag)
w.WriteHeader(http.StatusNotModified) w.WriteHeader(http.StatusNotModified)
return true return true
} }
} else if ifModifiedSinceHeader != "" { } else if ifModifiedSinceHeader != "" {
if t, parseError := time.Parse(http.TimeFormat, ifModifiedSinceHeader); parseError == nil { if t, parseError := time.Parse(http.TimeFormat, ifModifiedSinceHeader); parseError == nil {
if !t.Before(entry.Attr.Mtime) { if !t.Before(entry.Attr.Mtime) {
setEtag(w, etag)
w.WriteHeader(http.StatusNotModified) w.WriteHeader(http.StatusNotModified)
return true return true
} }
@ -147,11 +149,11 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
return return
} }
etag := filer.ETagEntry(entry)
if checkPreconditions(w, r, entry) { if checkPreconditions(w, r, entry) {
return return
} }
etag := filer.ETagEntry(entry)
w.Header().Set("Accept-Ranges", "bytes") w.Header().Set("Accept-Ranges", "bytes")
// mime type // mime type

Loading…
Cancel
Save