From 7d3f94911f35f03689a221525202f716936d50c6 Mon Sep 17 00:00:00 2001 From: xjtdy888 Date: Mon, 18 Jun 2018 14:14:17 +0800 Subject: [PATCH] cmd/syncthing: Correctly compare If-Modified-Since in HTTP server (#5016) --- cmd/syncthing/gui_statics.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/syncthing/gui_statics.go b/cmd/syncthing/gui_statics.go index b4023630b..1b788ba61 100644 --- a/cmd/syncthing/gui_statics.go +++ b/cmd/syncthing/gui_statics.go @@ -131,9 +131,11 @@ func (s *staticsServer) serveAsset(w http.ResponseWriter, r *http.Request) { w.Header().Set("Last-Modified", modified.Format(http.TimeFormat)) w.Header().Set("Etag", etag) - if t, err := time.Parse(http.TimeFormat, r.Header.Get("If-Modified-Since")); err == nil && modified.Add(time.Second).After(t) { - w.WriteHeader(http.StatusNotModified) - return + if t, err := time.Parse(http.TimeFormat, r.Header.Get("If-Modified-Since")); err == nil { + if modified.Equal(t) || modified.Before(t) { + w.WriteHeader(http.StatusNotModified) + return + } } if match := r.Header.Get("If-None-Match"); match != "" {