| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "net/http/http_log_util.h" | 5 #include "net/http/http_log_util.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "net/http/http_auth_challenge_tokenizer.h" | 9 #include "net/http/http_auth_challenge_tokenizer.h" |
| 10 #include "net/http/http_util.h" | 10 #include "net/http/http_util.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // Ignore Basic and Digest authentication challenges, as they contain | 27 // Ignore Basic and Digest authentication challenges, as they contain |
| 28 // public information. | 28 // public information. |
| 29 if (scheme == "basic" || scheme == "digest") | 29 if (scheme == "basic" || scheme == "digest") |
| 30 return false; | 30 return false; |
| 31 | 31 |
| 32 return true; | 32 return true; |
| 33 } | 33 } |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
| 38 void ElideChromeProxyDirective(const std::string& header_value, | 37 void ElideChromeProxyDirective(const std::string& header_value, |
| 39 const std::string& directive, | 38 const std::string& directive, |
| 40 std::string::const_iterator* redact_begin, | 39 std::string::const_iterator* redact_begin, |
| 41 std::string::const_iterator* redact_end) { | 40 std::string::const_iterator* redact_end) { |
| 42 HttpUtil::ValuesIterator it(header_value.begin(), header_value.end(), ','); | 41 HttpUtil::ValuesIterator it(header_value.begin(), header_value.end(), ','); |
| 43 while (it.GetNext()) { | 42 while (it.GetNext()) { |
| 44 if (LowerCaseEqualsASCII(it.value_begin(), | 43 if (LowerCaseEqualsASCII(it.value_begin(), |
| 45 it.value_begin() + directive.size(), | 44 it.value_begin() + directive.size(), |
| 46 directive.c_str())) { | 45 directive.c_str())) { |
| 47 *redact_begin = it.value_begin(); | 46 *redact_begin = it.value_begin(); |
| 48 *redact_end = it.value_end(); | 47 *redact_end = it.value_end(); |
| 49 return; | 48 return; |
| 50 } | 49 } |
| 51 } | 50 } |
| 52 } | 51 } |
| 53 #endif | |
| 54 | 52 |
| 55 std::string ElideHeaderValueForNetLog(NetLog::LogLevel log_level, | 53 std::string ElideHeaderValueForNetLog(NetLog::LogLevel log_level, |
| 56 const std::string& header, | 54 const std::string& header, |
| 57 const std::string& value) { | 55 const std::string& value) { |
| 58 std::string::const_iterator redact_begin = value.begin(); | 56 std::string::const_iterator redact_begin = value.begin(); |
| 59 std::string::const_iterator redact_end = value.begin(); | 57 std::string::const_iterator redact_end = value.begin(); |
| 60 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
| 61 if (!base::strcasecmp(header.c_str(), "chrome-proxy")) { | 58 if (!base::strcasecmp(header.c_str(), "chrome-proxy")) { |
| 62 ElideChromeProxyDirective(value, "sid=", &redact_begin, &redact_end); | 59 ElideChromeProxyDirective(value, "sid=", &redact_begin, &redact_end); |
| 63 } | 60 } |
| 64 #endif | |
| 65 | 61 |
| 66 if (redact_begin == redact_end && | 62 if (redact_begin == redact_end && |
| 67 log_level >= NetLog::LOG_STRIP_PRIVATE_DATA) { | 63 log_level >= NetLog::LOG_STRIP_PRIVATE_DATA) { |
| 68 | 64 |
| 69 // Note: this logic should be kept in sync with stripCookiesAndLoginInfo in | 65 // Note: this logic should be kept in sync with stripCookiesAndLoginInfo in |
| 70 // chrome/browser/resources/net_internals/log_view_painter.js. | 66 // chrome/browser/resources/net_internals/log_view_painter.js. |
| 71 | 67 |
| 72 if (!base::strcasecmp(header.c_str(), "set-cookie") || | 68 if (!base::strcasecmp(header.c_str(), "set-cookie") || |
| 73 !base::strcasecmp(header.c_str(), "set-cookie2") || | 69 !base::strcasecmp(header.c_str(), "set-cookie2") || |
| 74 !base::strcasecmp(header.c_str(), "cookie") || | 70 !base::strcasecmp(header.c_str(), "cookie") || |
| (...skipping 16 matching lines...) Expand all Loading... |
| 91 if (redact_begin == redact_end) | 87 if (redact_begin == redact_end) |
| 92 return value; | 88 return value; |
| 93 | 89 |
| 94 return std::string(value.begin(), redact_begin) + | 90 return std::string(value.begin(), redact_begin) + |
| 95 base::StringPrintf("[%ld bytes were stripped]", | 91 base::StringPrintf("[%ld bytes were stripped]", |
| 96 static_cast<long>(redact_end - redact_begin)) + | 92 static_cast<long>(redact_end - redact_begin)) + |
| 97 std::string(redact_end, value.end()); | 93 std::string(redact_end, value.end()); |
| 98 } | 94 } |
| 99 | 95 |
| 100 } // namespace net | 96 } // namespace net |
| OLD | NEW |