| 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 ]
|
|
|