OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 header parsing were borrowed from Firefox: | 5 // The rules for header parsing were borrowed from Firefox: |
6 // http://lxr.mozilla.org/seamonkey/source/netwerk/protocol/http/src/nsHttpRespo
nseHead.cpp | 6 // http://lxr.mozilla.org/seamonkey/source/netwerk/protocol/http/src/nsHttpRespo
nseHead.cpp |
7 // The rules for parsing content-types were also borrowed from Firefox: | 7 // The rules for parsing content-types were also borrowed from Firefox: |
8 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 | 8 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 |
9 | 9 |
10 #include "net/http/http_response_headers.h" | 10 #include "net/http/http_response_headers.h" |
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 bool HttpResponseHeaders::GetExpiresValue(Time* result) const { | 1040 bool HttpResponseHeaders::GetExpiresValue(Time* result) const { |
1041 return GetTimeValuedHeader("Expires", result); | 1041 return GetTimeValuedHeader("Expires", result); |
1042 } | 1042 } |
1043 | 1043 |
1044 bool HttpResponseHeaders::GetTimeValuedHeader(const std::string& name, | 1044 bool HttpResponseHeaders::GetTimeValuedHeader(const std::string& name, |
1045 Time* result) const { | 1045 Time* result) const { |
1046 std::string value; | 1046 std::string value; |
1047 if (!EnumerateHeader(NULL, name, &value)) | 1047 if (!EnumerateHeader(NULL, name, &value)) |
1048 return false; | 1048 return false; |
1049 | 1049 |
1050 std::wstring value_wide(value.begin(), value.end()); // inflate ascii | 1050 return Time::FromString(value.c_str(), result); |
1051 return Time::FromString(value_wide.c_str(), result); | |
1052 } | 1051 } |
1053 | 1052 |
1054 bool HttpResponseHeaders::IsKeepAlive() const { | 1053 bool HttpResponseHeaders::IsKeepAlive() const { |
1055 if (http_version_ < HttpVersion(1, 0)) | 1054 if (http_version_ < HttpVersion(1, 0)) |
1056 return false; | 1055 return false; |
1057 | 1056 |
1058 // NOTE: It is perhaps risky to assume that a Proxy-Connection header is | 1057 // NOTE: It is perhaps risky to assume that a Proxy-Connection header is |
1059 // meaningful when we don't know that this response was from a proxy, but | 1058 // meaningful when we don't know that this response was from a proxy, but |
1060 // Mozilla also does this, so we'll do the same. | 1059 // Mozilla also does this, so we'll do the same. |
1061 std::string connection_val; | 1060 std::string connection_val; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 // We have all the values; let's verify that they make sense for a 206 | 1231 // We have all the values; let's verify that they make sense for a 206 |
1233 // response. | 1232 // response. |
1234 if (*first_byte_position < 0 || *last_byte_position < 0 || | 1233 if (*first_byte_position < 0 || *last_byte_position < 0 || |
1235 *instance_length < 0 || *instance_length - 1 < *last_byte_position) | 1234 *instance_length < 0 || *instance_length - 1 < *last_byte_position) |
1236 return false; | 1235 return false; |
1237 | 1236 |
1238 return true; | 1237 return true; |
1239 } | 1238 } |
1240 | 1239 |
1241 } // namespace net | 1240 } // namespace net |
OLD | NEW |