Chromium Code Reviews| Index: net/http/http_util.cc |
| diff --git a/net/http/http_util.cc b/net/http/http_util.cc |
| index 6192c894145db1310e9668fbcfaebc89a260065f..31d15169515ff49170c45045a36b53f19cb51ce1 100644 |
| --- a/net/http/http_util.cc |
| +++ b/net/http/http_util.cc |
| @@ -738,6 +738,9 @@ bool HttpUtil::HasStrongValidators(HttpVersion version, |
| const std::string& etag_header, |
| const std::string& last_modified_header, |
| const std::string& date_header) { |
| + if (!HasValidators(version, etag_header, last_modified_header)) |
| + return false; |
| + |
| if (version < HttpVersion(1, 1)) |
|
gavinp
2016/02/26 15:32:59
Nit: I think this is redundant now.
jamartin
2016/02/29 14:40:01
No, it isn't. A message with LastModified, ETag an
gavinp
2016/02/29 14:44:01
Good point. I agree. Thanks.
|
| return false; |
| @@ -761,9 +764,27 @@ 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; |
| + |
| + // It is OK to consider an empty string in etag_header to be a missing header |
| + // since valid ETags are always quoted-strings (see RFC 2616 3.11) and thus |
| + // empty ETags aren't empty strings (i.e., "\"\""). |
|
gavinp
2016/02/26 15:32:59
Nit: how about (i.e. an empty ETag might be "\"\""
jamartin
2016/02/29 14:40:01
Done.
|
| + 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 |