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 | 14 |
14 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
16 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
17 #include "base/pickle.h" | 18 #include "base/pickle.h" |
18 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/string_piece.h" | 20 #include "base/strings/string_piece.h" |
20 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
21 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
22 #include "base/time/time.h" | 23 #include "base/time/time.h" |
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1400 std::string log_value = | 1401 std::string log_value = |
1401 ElideHeaderValueForNetLog(capture_mode, name, value); | 1402 ElideHeaderValueForNetLog(capture_mode, name, value); |
1402 std::string escaped_name = EscapeNonASCII(name); | 1403 std::string escaped_name = EscapeNonASCII(name); |
1403 std::string escaped_value = EscapeNonASCII(log_value); | 1404 std::string escaped_value = EscapeNonASCII(log_value); |
1404 headers->Append( | 1405 headers->Append( |
1405 new base::StringValue( | 1406 new base::StringValue( |
1406 base::StringPrintf("%s: %s", escaped_name.c_str(), | 1407 base::StringPrintf("%s: %s", escaped_name.c_str(), |
1407 escaped_value.c_str()))); | 1408 escaped_value.c_str()))); |
1408 } | 1409 } |
1409 dict->Set("headers", headers); | 1410 dict->Set("headers", headers); |
1410 return dict.Pass(); | 1411 return std::move(dict); |
1411 } | 1412 } |
1412 | 1413 |
1413 // static | 1414 // static |
1414 bool HttpResponseHeaders::FromNetLogParam( | 1415 bool HttpResponseHeaders::FromNetLogParam( |
1415 const base::Value* event_param, | 1416 const base::Value* event_param, |
1416 scoped_refptr<HttpResponseHeaders>* http_response_headers) { | 1417 scoped_refptr<HttpResponseHeaders>* http_response_headers) { |
1417 *http_response_headers = NULL; | 1418 *http_response_headers = NULL; |
1418 | 1419 |
1419 const base::DictionaryValue* dict = NULL; | 1420 const base::DictionaryValue* dict = NULL; |
1420 const base::ListValue* header_list = NULL; | 1421 const base::ListValue* header_list = NULL; |
(...skipping 20 matching lines...) Expand all Loading... |
1441 return true; | 1442 return true; |
1442 } | 1443 } |
1443 | 1444 |
1444 bool HttpResponseHeaders::IsChunkEncoded() const { | 1445 bool HttpResponseHeaders::IsChunkEncoded() const { |
1445 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. | 1446 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. |
1446 return GetHttpVersion() >= HttpVersion(1, 1) && | 1447 return GetHttpVersion() >= HttpVersion(1, 1) && |
1447 HasHeaderValue("Transfer-Encoding", "chunked"); | 1448 HasHeaderValue("Transfer-Encoding", "chunked"); |
1448 } | 1449 } |
1449 | 1450 |
1450 } // namespace net | 1451 } // namespace net |
OLD | NEW |