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 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 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1241 std::string last_modified_header; | 1241 std::string last_modified_header; |
| 1242 EnumerateHeader(nullptr, "Last-Modified", &last_modified_header); | 1242 EnumerateHeader(nullptr, "Last-Modified", &last_modified_header); |
| 1243 std::string date_header; | 1243 std::string date_header; |
| 1244 EnumerateHeader(nullptr, "Date", &date_header); | 1244 EnumerateHeader(nullptr, "Date", &date_header); |
| 1245 return HttpUtil::HasStrongValidators(GetHttpVersion(), | 1245 return HttpUtil::HasStrongValidators(GetHttpVersion(), |
| 1246 etag_header, | 1246 etag_header, |
| 1247 last_modified_header, | 1247 last_modified_header, |
| 1248 date_header); | 1248 date_header); |
| 1249 } | 1249 } |
| 1250 | 1250 |
| 1251 bool HttpResponseHeaders::HasValidators() const { | |
|
mmenke
2016/02/25 07:56:45
Erm...Wait...I'm not an expert on validators, but
jamartin
2016/02/25 11:30:49
Yes it should and I believe it is so in this imple
mmenke
2016/02/25 11:41:06
Sorry, I was just confused by the fact this actual
| |
| 1252 std::string etag_header; | |
| 1253 EnumerateHeader(NULL, "etag", &etag_header); | |
| 1254 std::string last_modified_header; | |
| 1255 EnumerateHeader(NULL, "Last-Modified", &last_modified_header); | |
| 1256 return HttpUtil::HasValidators(GetHttpVersion(), etag_header, | |
| 1257 last_modified_header); | |
| 1258 } | |
| 1259 | |
| 1251 // From RFC 2616: | 1260 // From RFC 2616: |
| 1252 // Content-Length = "Content-Length" ":" 1*DIGIT | 1261 // Content-Length = "Content-Length" ":" 1*DIGIT |
| 1253 int64_t HttpResponseHeaders::GetContentLength() const { | 1262 int64_t HttpResponseHeaders::GetContentLength() const { |
| 1254 return GetInt64HeaderValue("content-length"); | 1263 return GetInt64HeaderValue("content-length"); |
| 1255 } | 1264 } |
| 1256 | 1265 |
| 1257 int64_t HttpResponseHeaders::GetInt64HeaderValue( | 1266 int64_t HttpResponseHeaders::GetInt64HeaderValue( |
| 1258 const std::string& header) const { | 1267 const std::string& header) const { |
| 1259 size_t iter = 0; | 1268 size_t iter = 0; |
| 1260 std::string content_length_val; | 1269 std::string content_length_val; |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1442 return true; | 1451 return true; |
| 1443 } | 1452 } |
| 1444 | 1453 |
| 1445 bool HttpResponseHeaders::IsChunkEncoded() const { | 1454 bool HttpResponseHeaders::IsChunkEncoded() const { |
| 1446 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. | 1455 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. |
| 1447 return GetHttpVersion() >= HttpVersion(1, 1) && | 1456 return GetHttpVersion() >= HttpVersion(1, 1) && |
| 1448 HasHeaderValue("Transfer-Encoding", "chunked"); | 1457 HasHeaderValue("Transfer-Encoding", "chunked"); |
| 1449 } | 1458 } |
| 1450 | 1459 |
| 1451 } // namespace net | 1460 } // namespace net |
| OLD | NEW |