Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(980)

Unified Diff: net/http/http_util.cc

Issue 1481143002: Added HttpUtils::HasValidators and HttpResponse::HasValidators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed typos in the documentation Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/http/http_util.cc
diff --git a/net/http/http_util.cc b/net/http/http_util.cc
index f1e5143e701a5334499dccc9a814ae4c96d2023b..c49a992706c19112eb7b4ba57cd5e362050c7ea1 100644
--- a/net/http/http_util.cc
+++ b/net/http/http_util.cc
@@ -736,9 +736,24 @@ bool HttpUtil::HasStrongValidators(HttpVersion version,
if (!base::Time::FromString(date_header.c_str(), &date))
return false;
+ // Last-Modified is implicitly weak unless it is at least 60 seconds before
+ // the Date value.
return ((date - last_modified).InSeconds() >= 60);
}
+bool HttpUtil::HasValidators(HttpVersion version,
+ const std::string& etag_header,
+ const std::string& last_modified_header) {
+ if (version < HttpVersion(1, 0))
+ return false;
+
+ base::Time last_modified;
+ if (base::Time::FromString(last_modified_header.c_str(), &last_modified))
+ return true;
+
+ return version >= HttpVersion(1, 1) && !etag_header.empty();
+}
+
// Functions for histogram initialization. The code 0 is put in the map to
// track status codes that are invalid.
// TODO(gavinp): Greatly prune the collected codes once we learn which

Powered by Google App Engine
This is Rietveld 408576698