]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: use time.Compare
authorcuiweixie <cuiweixie@gmail.com>
Wed, 28 Sep 2022 00:23:21 +0000 (08:23 +0800)
committerGopher Robot <gobot@golang.org>
Thu, 29 Sep 2022 20:42:38 +0000 (20:42 +0000)
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>

src/net/http/cookiejar/jar.go
src/net/http/fs.go

index 097c93a137e8a59041a200a47b9247ecfc810319..3d0ad19af00ea4e134279f4d7270b3ca18485310 100644 (file)
@@ -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) {
                        return len(s[i].Path) > len(s[j].Path)
                }
-               if !s[i].Creation.Equal(s[j].Creation) {
-                       return s[i].Creation.Before(s[j].Creation)
+               if ret := s[i].Creation.Compare(s[j].Creation); ret != 0 {
+                       return ret < 0
                }
                return s[i].seqNum < s[j].seqNum
        })
index cf80018b5e1a8475cad2987d88bc31640ea5dc6d..3feef8f2b06ef67d0f97881993bd9d63f899ce0c 100644 (file)
@@ -431,7 +431,7 @@ func checkIfUnmodifiedSince(r *Request, modtime time.Time) condResult {
        // The Last-Modified header truncates sub-second precision so
        // the modtime needs to be truncated too.
        modtime = modtime.Truncate(time.Second)
-       if modtime.Before(t) || modtime.Equal(t) {
+       if ret := modtime.Compare(t); ret <= 0 {
                return condTrue
        }
        return condFalse
@@ -482,7 +482,7 @@ func checkIfModifiedSince(r *Request, modtime time.Time) condResult {
        // The Last-Modified header truncates sub-second precision so
        // the modtime needs to be truncated too.
        modtime = modtime.Truncate(time.Second)
-       if modtime.Before(t) || modtime.Equal(t) {
+       if ret := modtime.Compare(t); ret <= 0 {
                return condFalse
        }
        return condTrue