Browse Source
Merge pull request #1981 from ueni-ltd/if-modified-since
Fix If-Modified-Since behavior
pull/1997/head
Chris Lu
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
2 additions and
2 deletions
-
weed/s3api/s3api_object_handlers.go
-
weed/server/filer_server_handlers_read.go
|
@ -311,7 +311,7 @@ func (s3a *S3ApiServer) proxyToFiler(w http.ResponseWriter, r *http.Request, des |
|
|
} |
|
|
} |
|
|
defer util.CloseResponse(resp) |
|
|
defer util.CloseResponse(resp) |
|
|
|
|
|
|
|
|
if resp.ContentLength == -1 || resp.StatusCode == 404 { |
|
|
|
|
|
|
|
|
if (resp.ContentLength == -1 || resp.StatusCode == 404) && resp.StatusCode != 304 { |
|
|
if r.Method != "DELETE" { |
|
|
if r.Method != "DELETE" { |
|
|
writeErrorResponse(w, s3err.ErrNoSuchKey, r.URL) |
|
|
writeErrorResponse(w, s3err.ErrNoSuchKey, r.URL) |
|
|
return |
|
|
return |
|
|
|
@ -79,7 +79,7 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request, |
|
|
w.Header().Set("Last-Modified", entry.Attr.Mtime.UTC().Format(http.TimeFormat)) |
|
|
w.Header().Set("Last-Modified", entry.Attr.Mtime.UTC().Format(http.TimeFormat)) |
|
|
if r.Header.Get("If-Modified-Since") != "" { |
|
|
if r.Header.Get("If-Modified-Since") != "" { |
|
|
if t, parseError := time.Parse(http.TimeFormat, r.Header.Get("If-Modified-Since")); parseError == nil { |
|
|
if t, parseError := time.Parse(http.TimeFormat, r.Header.Get("If-Modified-Since")); parseError == nil { |
|
|
if t.After(entry.Attr.Mtime) { |
|
|
|
|
|
|
|
|
if t.After(entry.Attr.Mtime) || t.Equal(entry.Attr.Mtime) { |
|
|
w.WriteHeader(http.StatusNotModified) |
|
|
w.WriteHeader(http.StatusNotModified) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|