| 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" |
| 11 | 11 |
| 12 #include <algorithm> | 12 #include <algorithm> |
| 13 #include <utility> | 13 #include <utility> |
| 14 | 14 |
| 15 #include "base/trace_event/trace_event.h" |
| 15 #include "base/format_macros.h" | 16 #include "base/format_macros.h" |
| 16 #include "base/logging.h" | 17 #include "base/logging.h" |
| 17 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
| 18 #include "base/pickle.h" | 19 #include "base/pickle.h" |
| 19 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/string_piece.h" | 21 #include "base/strings/string_piece.h" |
| 21 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 22 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 23 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 24 #include "base/values.h" | 25 #include "base/values.h" |
| (...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 EnumerateHeader(nullptr, "Date", &date_header); | 1245 EnumerateHeader(nullptr, "Date", &date_header); |
| 1245 return HttpUtil::HasStrongValidators(GetHttpVersion(), | 1246 return HttpUtil::HasStrongValidators(GetHttpVersion(), |
| 1246 etag_header, | 1247 etag_header, |
| 1247 last_modified_header, | 1248 last_modified_header, |
| 1248 date_header); | 1249 date_header); |
| 1249 } | 1250 } |
| 1250 | 1251 |
| 1251 // From RFC 2616: | 1252 // From RFC 2616: |
| 1252 // Content-Length = "Content-Length" ":" 1*DIGIT | 1253 // Content-Length = "Content-Length" ":" 1*DIGIT |
| 1253 int64_t HttpResponseHeaders::GetContentLength() const { | 1254 int64_t HttpResponseHeaders::GetContentLength() const { |
| 1255 TRACE_EVENT0("toplevel", "HttpResponseHeaders::GetContentLength"); |
| 1254 return GetInt64HeaderValue("content-length"); | 1256 return GetInt64HeaderValue("content-length"); |
| 1255 } | 1257 } |
| 1256 | 1258 |
| 1257 int64_t HttpResponseHeaders::GetInt64HeaderValue( | 1259 int64_t HttpResponseHeaders::GetInt64HeaderValue( |
| 1258 const std::string& header) const { | 1260 const std::string& header) const { |
| 1259 size_t iter = 0; | 1261 size_t iter = 0; |
| 1260 std::string content_length_val; | 1262 std::string content_length_val; |
| 1261 if (!EnumerateHeader(&iter, header, &content_length_val)) | 1263 if (!EnumerateHeader(&iter, header, &content_length_val)) |
| 1262 return -1; | 1264 return -1; |
| 1263 | 1265 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 return true; | 1444 return true; |
| 1443 } | 1445 } |
| 1444 | 1446 |
| 1445 bool HttpResponseHeaders::IsChunkEncoded() const { | 1447 bool HttpResponseHeaders::IsChunkEncoded() const { |
| 1446 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. | 1448 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. |
| 1447 return GetHttpVersion() >= HttpVersion(1, 1) && | 1449 return GetHttpVersion() >= HttpVersion(1, 1) && |
| 1448 HasHeaderValue("Transfer-Encoding", "chunked"); | 1450 HasHeaderValue("Transfer-Encoding", "chunked"); |
| 1449 } | 1451 } |
| 1450 | 1452 |
| 1451 } // namespace net | 1453 } // namespace net |
| OLD | NEW |