mirror of
https://github.com/golang/go
synced 2024-11-22 04:04:40 -07:00
net/http: use mtime < t+1s to check for unmodified
The Date-Modified header truncates sub-second precision, so use mtime < t+1s instead of mtime <= t to check for unmodified. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5655052
This commit is contained in:
parent
3760213e6e
commit
c58b6ad022
@ -186,7 +186,10 @@ func checkLastModified(w ResponseWriter, r *Request, modtime time.Time) bool {
|
||||
if modtime.IsZero() {
|
||||
return false
|
||||
}
|
||||
if t, err := time.Parse(TimeFormat, r.Header.Get("If-Modified-Since")); err == nil && modtime.After(t) {
|
||||
|
||||
// The Date-Modified header truncates sub-second precision, so
|
||||
// use mtime < t+1s instead of mtime <= t to check for unmodified.
|
||||
if t, err := time.Parse(TimeFormat, r.Header.Get("If-Modified-Since")); err == nil && modtime.Before(t.Add(1*time.Second)) {
|
||||
w.WriteHeader(StatusNotModified)
|
||||
return true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user