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 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1348 base::Value* HttpResponseHeaders::NetLogCallback( | 1348 base::Value* HttpResponseHeaders::NetLogCallback( |
1349 NetLog::LogLevel log_level) const { | 1349 NetLog::LogLevel log_level) const { |
1350 base::DictionaryValue* dict = new base::DictionaryValue(); | 1350 base::DictionaryValue* dict = new base::DictionaryValue(); |
1351 base::ListValue* headers = new base::ListValue(); | 1351 base::ListValue* headers = new base::ListValue(); |
1352 headers->Append(new base::StringValue(GetStatusLine())); | 1352 headers->Append(new base::StringValue(GetStatusLine())); |
1353 void* iterator = NULL; | 1353 void* iterator = NULL; |
1354 std::string name; | 1354 std::string name; |
1355 std::string value; | 1355 std::string value; |
1356 while (EnumerateHeaderLines(&iterator, &name, &value)) { | 1356 while (EnumerateHeaderLines(&iterator, &name, &value)) { |
1357 std::string log_value = ElideHeaderValueForNetLog(log_level, name, value); | 1357 std::string log_value = ElideHeaderValueForNetLog(log_level, name, value); |
1358 std::string escaped_name = EscapeNonASCII(name); | |
1359 std::string escaped_value = EscapeNonASCII(log_value); | |
1358 headers->Append( | 1360 headers->Append( |
1359 new base::StringValue( | 1361 new base::StringValue( |
1360 base::StringPrintf("%s: %s", name.c_str(), log_value.c_str()))); | 1362 base::StringPrintf("%s: %s", escaped_name.c_str(), |
davidben
2014/08/07 17:36:36
Header names and values are "supposed to be" treat
Elly Fong-Jones
2014/08/07 19:41:37
Acknowledged.
| |
1363 escaped_value.c_str()))); | |
1361 } | 1364 } |
1362 dict->Set("headers", headers); | 1365 dict->Set("headers", headers); |
1363 return dict; | 1366 return dict; |
1364 } | 1367 } |
1365 | 1368 |
1366 // static | 1369 // static |
1367 bool HttpResponseHeaders::FromNetLogParam( | 1370 bool HttpResponseHeaders::FromNetLogParam( |
1368 const base::Value* event_param, | 1371 const base::Value* event_param, |
1369 scoped_refptr<HttpResponseHeaders>* http_response_headers) { | 1372 scoped_refptr<HttpResponseHeaders>* http_response_headers) { |
1370 *http_response_headers = NULL; | 1373 *http_response_headers = NULL; |
(...skipping 23 matching lines...) Expand all Loading... | |
1394 return true; | 1397 return true; |
1395 } | 1398 } |
1396 | 1399 |
1397 bool HttpResponseHeaders::IsChunkEncoded() const { | 1400 bool HttpResponseHeaders::IsChunkEncoded() const { |
1398 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. | 1401 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. |
1399 return GetHttpVersion() >= HttpVersion(1, 1) && | 1402 return GetHttpVersion() >= HttpVersion(1, 1) && |
1400 HasHeaderValue("Transfer-Encoding", "chunked"); | 1403 HasHeaderValue("Transfer-Encoding", "chunked"); |
1401 } | 1404 } |
1402 | 1405 |
1403 } // namespace net | 1406 } // namespace net |
OLD | NEW |