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

Unified Diff: net/http/http_util.cc

Issue 10387200: Suppress pause-and-buffer behavior when the HTTP response won't satisfy future requests via cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: %zu is win-unfriendly; use %PRIuS instead. Created 8 years, 7 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
« no previous file with comments | « net/http/http_util.h ('k') | webkit/media/buffered_data_source.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_util.cc
diff --git a/net/http/http_util.cc b/net/http/http_util.cc
index a5dc3911ffc2832358e31515d907601ea95ddb1d..0a9c6a6f3a75f536a709ebe28daef58ee12c1ae5 100644
--- a/net/http/http_util.cc
+++ b/net/http/http_util.cc
@@ -15,6 +15,7 @@
#include "base/string_number_conversions.h"
#include "base/string_piece.h"
#include "base/string_util.h"
+#include "base/time.h"
using std::string;
@@ -699,6 +700,36 @@ void HttpUtil::AppendHeaderIfMissing(const char* header_name,
*headers += std::string(header_name) + ": " + header_value + "\r\n";
}
+bool HttpUtil::HasStrongValidators(HttpVersion version,
+ const std::string& etag_header,
+ const std::string& last_modified_header,
+ const std::string& date_header) {
+ if (version < HttpVersion(1, 1))
+ return false;
+
+ if (!etag_header.empty()) {
+ size_t slash = etag_header.find('/');
+ if (slash == std::string::npos || slash == 0)
+ return true;
+
+ std::string::const_iterator i = etag_header.begin();
+ std::string::const_iterator j = etag_header.begin() + slash;
+ TrimLWS(&i, &j);
+ if (!LowerCaseEqualsASCII(i, j, "w"))
+ return true;
+ }
+
+ base::Time last_modified;
+ if (!base::Time::FromString(last_modified_header.c_str(), &last_modified))
+ return false;
+
+ base::Time date;
+ if (!base::Time::FromString(date_header.c_str(), &date))
+ return false;
+
+ return ((date - last_modified).InSeconds() >= 60);
+}
+
// BNF from section 4.2 of RFC 2616:
//
// message-header = field-name ":" [ field-value ]
« no previous file with comments | « net/http/http_util.h ('k') | webkit/media/buffered_data_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698