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

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: Extracted GetReasonsForUncacheability and added tests. 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
Index: net/http/http_util.cc
diff --git a/net/http/http_util.cc b/net/http/http_util.cc
index a5dc3911ffc2832358e31515d907601ea95ddb1d..1330effb9152523274abbbf000c9feaa37b865b9 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,37 @@ void HttpUtil::AppendHeaderIfMissing(const char* header_name,
*headers += std::string(header_name) + ": " + header_value + "\r\n";
}
+bool HttpUtil::HasStrongValidators(
+ HttpVersion version,
rvargas (doing something else) 2012/05/23 02:04:12 nit: arguments should start on the previous line.
Ami GONE FROM CHROMIUM 2012/05/23 03:55:23 No, because that makes the second & subsequent arg
rvargas (doing something else) 2012/05/23 18:26:09 (warning, rietveld may ruin formatting) bool Http
Ami GONE FROM CHROMIUM 2012/05/23 19:29:51 Ah; I thought you were asking for mixed style, bec
+ 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 ]

Powered by Google App Engine
This is Rietveld 408576698