| 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 // Last-Modified is implicitly weak unless it is at least 60 seconds before |
| 740 // the Date value. |
| 739 return ((date - last_modified).InSeconds() >= 60); | 741 return ((date - last_modified).InSeconds() >= 60); |
| 740 } | 742 } |
| 741 | 743 |
| 744 bool HttpUtil::HasValidators(HttpVersion version, |
| 745 const std::string& etag_header, |
| 746 const std::string& last_modified_header) { |
| 747 if (version < HttpVersion(1, 0)) |
| 748 return false; |
| 749 |
| 750 base::Time last_modified; |
| 751 if (base::Time::FromString(last_modified_header.c_str(), &last_modified)) |
| 752 return true; |
| 753 |
| 754 return version >= HttpVersion(1, 1) && !etag_header.empty(); |
| 755 } |
| 756 |
| 742 // Functions for histogram initialization. The code 0 is put in the map to | 757 // Functions for histogram initialization. The code 0 is put in the map to |
| 743 // track status codes that are invalid. | 758 // track status codes that are invalid. |
| 744 // TODO(gavinp): Greatly prune the collected codes once we learn which | 759 // TODO(gavinp): Greatly prune the collected codes once we learn which |
| 745 // ones are not sent in practice, to reduce upload size & memory use. | 760 // ones are not sent in practice, to reduce upload size & memory use. |
| 746 | 761 |
| 747 enum { | 762 enum { |
| 748 HISTOGRAM_MIN_HTTP_STATUS_CODE = 100, | 763 HISTOGRAM_MIN_HTTP_STATUS_CODE = 100, |
| 749 HISTOGRAM_MAX_HTTP_STATUS_CODE = 599, | 764 HISTOGRAM_MAX_HTTP_STATUS_CODE = 599, |
| 750 }; | 765 }; |
| 751 | 766 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 value_is_quoted_ = true; | 956 value_is_quoted_ = true; |
| 942 // Do not store iterators into this. See declaration of unquoted_value_. | 957 // Do not store iterators into this. See declaration of unquoted_value_. |
| 943 unquoted_value_ = HttpUtil::Unquote(value_begin_, value_end_); | 958 unquoted_value_ = HttpUtil::Unquote(value_begin_, value_end_); |
| 944 } | 959 } |
| 945 } | 960 } |
| 946 | 961 |
| 947 return true; | 962 return true; |
| 948 } | 963 } |
| 949 | 964 |
| 950 } // namespace net | 965 } // namespace net |
| OLD | NEW |