| 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 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 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 std::string last_modified_header; | 1235 std::string last_modified_header; |
| 1236 EnumerateHeader(NULL, "Last-Modified", &last_modified_header); | 1236 EnumerateHeader(NULL, "Last-Modified", &last_modified_header); |
| 1237 std::string date_header; | 1237 std::string date_header; |
| 1238 EnumerateHeader(NULL, "Date", &date_header); | 1238 EnumerateHeader(NULL, "Date", &date_header); |
| 1239 return HttpUtil::HasStrongValidators(GetHttpVersion(), | 1239 return HttpUtil::HasStrongValidators(GetHttpVersion(), |
| 1240 etag_header, | 1240 etag_header, |
| 1241 last_modified_header, | 1241 last_modified_header, |
| 1242 date_header); | 1242 date_header); |
| 1243 } | 1243 } |
| 1244 | 1244 |
| 1245 bool HttpResponseHeaders::HasValidators() const { |
| 1246 std::string etag_header; |
| 1247 EnumerateHeader(NULL, "etag", &etag_header); |
| 1248 std::string last_modified_header; |
| 1249 EnumerateHeader(NULL, "Last-Modified", &last_modified_header); |
| 1250 return HttpUtil::HasValidators(GetHttpVersion(), etag_header, |
| 1251 last_modified_header); |
| 1252 } |
| 1253 |
| 1245 // From RFC 2616: | 1254 // From RFC 2616: |
| 1246 // Content-Length = "Content-Length" ":" 1*DIGIT | 1255 // Content-Length = "Content-Length" ":" 1*DIGIT |
| 1247 int64 HttpResponseHeaders::GetContentLength() const { | 1256 int64 HttpResponseHeaders::GetContentLength() const { |
| 1248 return GetInt64HeaderValue("content-length"); | 1257 return GetInt64HeaderValue("content-length"); |
| 1249 } | 1258 } |
| 1250 | 1259 |
| 1251 int64 HttpResponseHeaders::GetInt64HeaderValue( | 1260 int64 HttpResponseHeaders::GetInt64HeaderValue( |
| 1252 const std::string& header) const { | 1261 const std::string& header) const { |
| 1253 void* iter = NULL; | 1262 void* iter = NULL; |
| 1254 std::string content_length_val; | 1263 std::string content_length_val; |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1436 return true; | 1445 return true; |
| 1437 } | 1446 } |
| 1438 | 1447 |
| 1439 bool HttpResponseHeaders::IsChunkEncoded() const { | 1448 bool HttpResponseHeaders::IsChunkEncoded() const { |
| 1440 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. | 1449 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. |
| 1441 return GetHttpVersion() >= HttpVersion(1, 1) && | 1450 return GetHttpVersion() >= HttpVersion(1, 1) && |
| 1442 HasHeaderValue("Transfer-Encoding", "chunked"); | 1451 HasHeaderValue("Transfer-Encoding", "chunked"); |
| 1443 } | 1452 } |
| 1444 | 1453 |
| 1445 } // namespace net | 1454 } // namespace net |
| OLD | NEW |