mirror of https://github.com/golang/go.git
net/http: use time.Compare
Change-Id: I4730673130bdfbda9987dcb5869f421082f92150 Reviewed-on: https://go-review.googlesource.com/c/go/+/435615 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
This commit is contained in:
parent
27d4cdd1a6
commit
879f595f7e
|
|
@ -214,8 +214,8 @@ func (j *Jar) cookies(u *url.URL, now time.Time) (cookies []*http.Cookie) {
|
||||||
if len(s[i].Path) != len(s[j].Path) {
|
if len(s[i].Path) != len(s[j].Path) {
|
||||||
return len(s[i].Path) > len(s[j].Path)
|
return len(s[i].Path) > len(s[j].Path)
|
||||||
}
|
}
|
||||||
if !s[i].Creation.Equal(s[j].Creation) {
|
if ret := s[i].Creation.Compare(s[j].Creation); ret != 0 {
|
||||||
return s[i].Creation.Before(s[j].Creation)
|
return ret < 0
|
||||||
}
|
}
|
||||||
return s[i].seqNum < s[j].seqNum
|
return s[i].seqNum < s[j].seqNum
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -431,7 +431,7 @@ func checkIfUnmodifiedSince(r *Request, modtime time.Time) condResult {
|
||||||
// The Last-Modified header truncates sub-second precision so
|
// The Last-Modified header truncates sub-second precision so
|
||||||
// the modtime needs to be truncated too.
|
// the modtime needs to be truncated too.
|
||||||
modtime = modtime.Truncate(time.Second)
|
modtime = modtime.Truncate(time.Second)
|
||||||
if modtime.Before(t) || modtime.Equal(t) {
|
if ret := modtime.Compare(t); ret <= 0 {
|
||||||
return condTrue
|
return condTrue
|
||||||
}
|
}
|
||||||
return condFalse
|
return condFalse
|
||||||
|
|
@ -482,7 +482,7 @@ func checkIfModifiedSince(r *Request, modtime time.Time) condResult {
|
||||||
// The Last-Modified header truncates sub-second precision so
|
// The Last-Modified header truncates sub-second precision so
|
||||||
// the modtime needs to be truncated too.
|
// the modtime needs to be truncated too.
|
||||||
modtime = modtime.Truncate(time.Second)
|
modtime = modtime.Truncate(time.Second)
|
||||||
if modtime.Before(t) || modtime.Equal(t) {
|
if ret := modtime.Compare(t); ret <= 0 {
|
||||||
return condFalse
|
return condFalse
|
||||||
}
|
}
|
||||||
return condTrue
|
return condTrue
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue