Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // The rules for parsing content-types were borrowed from Firefox: | 5 // The rules for parsing content-types were borrowed from Firefox: |
| 6 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 | 6 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 |
| 7 | 7 |
| 8 #include "net/http/http_util.h" | 8 #include "net/http/http_util.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 729 } | 729 } |
| 730 | 730 |
| 731 base::Time last_modified; | 731 base::Time last_modified; |
| 732 if (!base::Time::FromString(last_modified_header.c_str(), &last_modified)) | 732 if (!base::Time::FromString(last_modified_header.c_str(), &last_modified)) |
| 733 return false; | 733 return false; |
| 734 | 734 |
| 735 base::Time date; | 735 base::Time date; |
| 736 if (!base::Time::FromString(date_header.c_str(), &date)) | 736 if (!base::Time::FromString(date_header.c_str(), &date)) |
| 737 return false; | 737 return false; |
| 738 | 738 |
| 739 return ((date - last_modified).InSeconds() >= 60); | 739 return ((date - last_modified).InSeconds() >= 60); |
|
bengr
2015/12/03 17:42:21
I'd add a comment here that a Last-Modified header
jamartin (wrong)
2015/12/08 16:58:18
Done.
| |
| 740 } | 740 } |
| 741 | 741 |
| 742 bool HttpUtil::HasValidators(HttpVersion version, | |
| 743 const std::string& etag_header, | |
| 744 const std::string& last_modified_header) { | |
| 745 if (version < HttpVersion(1, 0)) | |
| 746 return false; | |
| 747 | |
| 748 base::Time last_modified; | |
| 749 if (base::Time::FromString(last_modified_header.c_str(), &last_modified)) | |
| 750 return true; | |
| 751 | |
| 752 return version >= HttpVersion(1, 1) && !etag_header.empty(); | |
| 753 } | |
| 754 | |
| 742 // Functions for histogram initialization. The code 0 is put in the map to | 755 // Functions for histogram initialization. The code 0 is put in the map to |
| 743 // track status codes that are invalid. | 756 // track status codes that are invalid. |
| 744 // TODO(gavinp): Greatly prune the collected codes once we learn which | 757 // TODO(gavinp): Greatly prune the collected codes once we learn which |
| 745 // ones are not sent in practice, to reduce upload size & memory use. | 758 // ones are not sent in practice, to reduce upload size & memory use. |
| 746 | 759 |
| 747 enum { | 760 enum { |
| 748 HISTOGRAM_MIN_HTTP_STATUS_CODE = 100, | 761 HISTOGRAM_MIN_HTTP_STATUS_CODE = 100, |
| 749 HISTOGRAM_MAX_HTTP_STATUS_CODE = 599, | 762 HISTOGRAM_MAX_HTTP_STATUS_CODE = 599, |
| 750 }; | 763 }; |
| 751 | 764 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 941 value_is_quoted_ = true; | 954 value_is_quoted_ = true; |
| 942 // Do not store iterators into this. See declaration of unquoted_value_. | 955 // Do not store iterators into this. See declaration of unquoted_value_. |
| 943 unquoted_value_ = HttpUtil::Unquote(value_begin_, value_end_); | 956 unquoted_value_ = HttpUtil::Unquote(value_begin_, value_end_); |
| 944 } | 957 } |
| 945 } | 958 } |
| 946 | 959 |
| 947 return true; | 960 return true; |
| 948 } | 961 } |
| 949 | 962 |
| 950 } // namespace net | 963 } // namespace net |
| OLD | NEW |