| 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_number_conversions.h" | |
| 8 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 9 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 10 #include "base/values.h" | |
| 11 #include "net/http/http_auth_challenge_tokenizer.h" | 9 #include "net/http/http_auth_challenge_tokenizer.h" |
| 12 #include "net/http/http_auth_scheme.h" | 10 #include "net/http/http_auth_scheme.h" |
| 13 #include "net/http/http_util.h" | |
| 14 #include "net/log/net_log_capture_mode.h" | |
| 15 | 11 |
| 16 namespace net { | 12 namespace net { |
| 17 | 13 |
| 18 namespace { | 14 namespace { |
| 19 | 15 |
| 20 bool ShouldRedactChallenge(HttpAuthChallengeTokenizer* challenge) { | 16 bool ShouldRedactChallenge(HttpAuthChallengeTokenizer* challenge) { |
| 21 // Ignore lines with commas, as they may contain lists of schemes, and | 17 // Ignore lines with commas, as they may contain lists of schemes, and |
| 22 // the information we want to hide is Base64 encoded, so has no commas. | 18 // the information we want to hide is Base64 encoded, so has no commas. |
| 23 if (challenge->challenge_text().find(',') != std::string::npos) | 19 if (challenge->challenge_text().find(',') != std::string::npos) |
| 24 return false; | 20 return false; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 66 |
| 71 if (redact_begin == redact_end) | 67 if (redact_begin == redact_end) |
| 72 return value; | 68 return value; |
| 73 | 69 |
| 74 return std::string(value.begin(), redact_begin) + | 70 return std::string(value.begin(), redact_begin) + |
| 75 base::StringPrintf("[%ld bytes were stripped]", | 71 base::StringPrintf("[%ld bytes were stripped]", |
| 76 static_cast<long>(redact_end - redact_begin)) + | 72 static_cast<long>(redact_end - redact_begin)) + |
| 77 std::string(redact_end, value.end()); | 73 std::string(redact_end, value.end()); |
| 78 } | 74 } |
| 79 | 75 |
| 80 std::string ElideGoAwayDebugDataForNetLog(NetLogCaptureMode capture_mode, | |
| 81 base::StringPiece debug_data) { | |
| 82 // Note: this logic should be kept in sync with stripGoAwayDebugData in | |
| 83 // chrome/browser/resources/net_internals/log_view_painter.js. | |
| 84 if (capture_mode.include_cookies_and_credentials()) { | |
| 85 return debug_data.as_string(); | |
| 86 } | |
| 87 | |
| 88 return std::string("[") + base::SizeTToString(debug_data.size()) + | |
| 89 std::string(" bytes were stripped]"); | |
| 90 } | |
| 91 | |
| 92 std::unique_ptr<base::ListValue> ElideSpdyHeaderBlockForNetLog( | |
| 93 const SpdyHeaderBlock& headers, | |
| 94 NetLogCaptureMode capture_mode) { | |
| 95 std::unique_ptr<base::ListValue> headers_list(new base::ListValue()); | |
| 96 for (SpdyHeaderBlock::const_iterator it = headers.begin(); | |
| 97 it != headers.end(); ++it) { | |
| 98 headers_list->AppendString( | |
| 99 it->first.as_string() + ": " + | |
| 100 ElideHeaderValueForNetLog(capture_mode, it->first.as_string(), | |
| 101 it->second.as_string())); | |
| 102 } | |
| 103 return headers_list; | |
| 104 } | |
| 105 | |
| 106 } // namespace net | 76 } // namespace net |
| OLD | NEW |