| 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 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1385 // We have all the values; let's verify that they make sense for a 206 | 1385 // We have all the values; let's verify that they make sense for a 206 |
| 1386 // response. | 1386 // response. |
| 1387 if (*first_byte_position < 0 || *last_byte_position < 0 || | 1387 if (*first_byte_position < 0 || *last_byte_position < 0 || |
| 1388 *instance_length < 0 || *instance_length - 1 < *last_byte_position) | 1388 *instance_length < 0 || *instance_length - 1 < *last_byte_position) |
| 1389 return false; | 1389 return false; |
| 1390 | 1390 |
| 1391 return true; | 1391 return true; |
| 1392 } | 1392 } |
| 1393 | 1393 |
| 1394 base::Value* HttpResponseHeaders::NetLogCallback( | 1394 base::Value* HttpResponseHeaders::NetLogCallback( |
| 1395 NetLog::LogLevel log_level) const { | 1395 NetLogCaptureMode capture_mode) const { |
| 1396 base::DictionaryValue* dict = new base::DictionaryValue(); | 1396 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 1397 base::ListValue* headers = new base::ListValue(); | 1397 base::ListValue* headers = new base::ListValue(); |
| 1398 headers->Append(new base::StringValue(GetStatusLine())); | 1398 headers->Append(new base::StringValue(GetStatusLine())); |
| 1399 void* iterator = NULL; | 1399 void* iterator = NULL; |
| 1400 std::string name; | 1400 std::string name; |
| 1401 std::string value; | 1401 std::string value; |
| 1402 while (EnumerateHeaderLines(&iterator, &name, &value)) { | 1402 while (EnumerateHeaderLines(&iterator, &name, &value)) { |
| 1403 std::string log_value = ElideHeaderValueForNetLog(log_level, name, value); | 1403 std::string log_value = |
| 1404 ElideHeaderValueForNetLog(capture_mode, name, value); |
| 1404 std::string escaped_name = EscapeNonASCII(name); | 1405 std::string escaped_name = EscapeNonASCII(name); |
| 1405 std::string escaped_value = EscapeNonASCII(log_value); | 1406 std::string escaped_value = EscapeNonASCII(log_value); |
| 1406 headers->Append( | 1407 headers->Append( |
| 1407 new base::StringValue( | 1408 new base::StringValue( |
| 1408 base::StringPrintf("%s: %s", escaped_name.c_str(), | 1409 base::StringPrintf("%s: %s", escaped_name.c_str(), |
| 1409 escaped_value.c_str()))); | 1410 escaped_value.c_str()))); |
| 1410 } | 1411 } |
| 1411 dict->Set("headers", headers); | 1412 dict->Set("headers", headers); |
| 1412 return dict; | 1413 return dict; |
| 1413 } | 1414 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1443 return true; | 1444 return true; |
| 1444 } | 1445 } |
| 1445 | 1446 |
| 1446 bool HttpResponseHeaders::IsChunkEncoded() const { | 1447 bool HttpResponseHeaders::IsChunkEncoded() const { |
| 1447 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. | 1448 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. |
| 1448 return GetHttpVersion() >= HttpVersion(1, 1) && | 1449 return GetHttpVersion() >= HttpVersion(1, 1) && |
| 1449 HasHeaderValue("Transfer-Encoding", "chunked"); | 1450 HasHeaderValue("Transfer-Encoding", "chunked"); |
| 1450 } | 1451 } |
| 1451 | 1452 |
| 1452 } // namespace net | 1453 } // namespace net |
| OLD | NEW |