Chromium Code Reviews| 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 ] |