浏览代码

cmd/syncthing: Correctly compare If-Modified-Since in HTTP server (#5016)

xjtdy888 7 年之前
父节点
当前提交
7d3f94911f
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5 3
      cmd/syncthing/gui_statics.go

+ 5 - 3
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("Last-Modified", modified.Format(http.TimeFormat))
 	w.Header().Set("Etag", etag)
 	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 != "" {
 	if match := r.Header.Get("If-None-Match"); match != "" {