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 std::string ElideHeaderValueForNetLog(NetLog::LogLevel log_level, | 37 std::string ElideHeaderValueForNetLog(NetLogCaptureMode capture_mode, |
38 const std::string& header, | 38 const std::string& header, |
39 const std::string& value) { | 39 const std::string& value) { |
40 std::string::const_iterator redact_begin = value.begin(); | 40 std::string::const_iterator redact_begin = value.begin(); |
41 std::string::const_iterator redact_end = value.begin(); | 41 std::string::const_iterator redact_end = value.begin(); |
42 | 42 |
43 if (redact_begin == redact_end && | 43 if (redact_begin == redact_end && |
44 log_level >= NetLog::LOG_STRIP_PRIVATE_DATA) { | 44 !capture_mode.include_cookies_and_credentials()) { |
45 | |
46 // Note: this logic should be kept in sync with stripCookiesAndLoginInfo in | 45 // Note: this logic should be kept in sync with stripCookiesAndLoginInfo in |
47 // chrome/browser/resources/net_internals/log_view_painter.js. | 46 // chrome/browser/resources/net_internals/log_view_painter.js. |
48 | 47 |
49 if (!base::strcasecmp(header.c_str(), "set-cookie") || | 48 if (!base::strcasecmp(header.c_str(), "set-cookie") || |
50 !base::strcasecmp(header.c_str(), "set-cookie2") || | 49 !base::strcasecmp(header.c_str(), "set-cookie2") || |
51 !base::strcasecmp(header.c_str(), "cookie") || | 50 !base::strcasecmp(header.c_str(), "cookie") || |
52 !base::strcasecmp(header.c_str(), "authorization") || | 51 !base::strcasecmp(header.c_str(), "authorization") || |
53 !base::strcasecmp(header.c_str(), "proxy-authorization")) { | 52 !base::strcasecmp(header.c_str(), "proxy-authorization")) { |
54 redact_begin = value.begin(); | 53 redact_begin = value.begin(); |
55 redact_end = value.end(); | 54 redact_end = value.end(); |
(...skipping 12 matching lines...) Expand all Loading... |
68 if (redact_begin == redact_end) | 67 if (redact_begin == redact_end) |
69 return value; | 68 return value; |
70 | 69 |
71 return std::string(value.begin(), redact_begin) + | 70 return std::string(value.begin(), redact_begin) + |
72 base::StringPrintf("[%ld bytes were stripped]", | 71 base::StringPrintf("[%ld bytes were stripped]", |
73 static_cast<long>(redact_end - redact_begin)) + | 72 static_cast<long>(redact_end - redact_begin)) + |
74 std::string(redact_end, value.end()); | 73 std::string(redact_end, value.end()); |
75 } | 74 } |
76 | 75 |
77 } // namespace net | 76 } // namespace net |
OLD | NEW |