| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 return true; | 106 return true; |
| 107 } | 107 } |
| 108 | 108 |
| 109 void CheckDoesNotHaveEmbededNulls(const std::string& str) { | 109 void CheckDoesNotHaveEmbededNulls(const std::string& str) { |
| 110 // Care needs to be taken when adding values to the raw headers string to | 110 // Care needs to be taken when adding values to the raw headers string to |
| 111 // make sure it does not contain embeded NULLs. Any embeded '\0' may be | 111 // make sure it does not contain embeded NULLs. Any embeded '\0' may be |
| 112 // understood as line terminators and change how header lines get tokenized. | 112 // understood as line terminators and change how header lines get tokenized. |
| 113 CHECK(str.find('\0') == std::string::npos); | 113 CHECK(str.find('\0') == std::string::npos); |
| 114 } | 114 } |
| 115 | 115 |
| 116 bool ShouldShowHttpHeaderValue(const std::string& header_name) { |
| 117 #if defined(SPDY_PROXY_AUTH_ORIGIN) |
| 118 if (header_name == "Proxy-Authenticate") |
| 119 return false; |
| 120 #endif |
| 121 return true; |
| 122 } |
| 123 |
| 116 } // namespace | 124 } // namespace |
| 117 | 125 |
| 118 const char HttpResponseHeaders::kContentRange[] = "Content-Range"; | 126 const char HttpResponseHeaders::kContentRange[] = "Content-Range"; |
| 119 | 127 |
| 120 struct HttpResponseHeaders::ParsedHeader { | 128 struct HttpResponseHeaders::ParsedHeader { |
| 121 // A header "continuation" contains only a subsequent value for the | 129 // A header "continuation" contains only a subsequent value for the |
| 122 // preceding header. (Header values are comma separated.) | 130 // preceding header. (Header values are comma separated.) |
| 123 bool is_continuation() const { return name_begin == name_end; } | 131 bool is_continuation() const { return name_begin == name_end; } |
| 124 | 132 |
| 125 std::string::const_iterator name_begin; | 133 std::string::const_iterator name_begin; |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1304 base::Value* HttpResponseHeaders::NetLogCallback( | 1312 base::Value* HttpResponseHeaders::NetLogCallback( |
| 1305 NetLog::LogLevel /* log_level */) const { | 1313 NetLog::LogLevel /* log_level */) const { |
| 1306 base::DictionaryValue* dict = new base::DictionaryValue(); | 1314 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 1307 base::ListValue* headers = new base::ListValue(); | 1315 base::ListValue* headers = new base::ListValue(); |
| 1308 headers->Append(new base::StringValue(GetStatusLine())); | 1316 headers->Append(new base::StringValue(GetStatusLine())); |
| 1309 void* iterator = NULL; | 1317 void* iterator = NULL; |
| 1310 std::string name; | 1318 std::string name; |
| 1311 std::string value; | 1319 std::string value; |
| 1312 while (EnumerateHeaderLines(&iterator, &name, &value)) { | 1320 while (EnumerateHeaderLines(&iterator, &name, &value)) { |
| 1313 headers->Append( | 1321 headers->Append( |
| 1314 new base::StringValue(base::StringPrintf("%s: %s", | 1322 new base::StringValue( |
| 1315 name.c_str(), | 1323 base::StringPrintf("%s: %s", |
| 1316 value.c_str()))); | 1324 name.c_str(), |
| 1325 (ShouldShowHttpHeaderValue(name) ? |
| 1326 value.c_str() : "[elided]")))); |
| 1317 } | 1327 } |
| 1318 dict->Set("headers", headers); | 1328 dict->Set("headers", headers); |
| 1319 return dict; | 1329 return dict; |
| 1320 } | 1330 } |
| 1321 | 1331 |
| 1322 // static | 1332 // static |
| 1323 bool HttpResponseHeaders::FromNetLogParam( | 1333 bool HttpResponseHeaders::FromNetLogParam( |
| 1324 const base::Value* event_param, | 1334 const base::Value* event_param, |
| 1325 scoped_refptr<HttpResponseHeaders>* http_response_headers) { | 1335 scoped_refptr<HttpResponseHeaders>* http_response_headers) { |
| 1326 *http_response_headers = NULL; | 1336 *http_response_headers = NULL; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 | 1415 |
| 1406 // Next, look for 'bypass'. | 1416 // Next, look for 'bypass'. |
| 1407 if (GetChromeProxyBypassDuration("bypass=", &proxy_info->bypass_duration)) | 1417 if (GetChromeProxyBypassDuration("bypass=", &proxy_info->bypass_duration)) |
| 1408 return true; | 1418 return true; |
| 1409 | 1419 |
| 1410 return false; | 1420 return false; |
| 1411 } | 1421 } |
| 1412 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | 1422 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) |
| 1413 | 1423 |
| 1414 } // namespace net | 1424 } // namespace net |
| OLD | NEW |