Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Side by Side Diff: net/http/http_log_util.cc

Issue 1157333005: [net/http auth] Use strings to identify authentication schemes. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_auth_unittest.cc ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 11
12 namespace net { 12 namespace net {
13 13
14 namespace { 14 namespace {
15 15
16 bool ShouldRedactChallenge(HttpAuthChallengeTokenizer* challenge) { 16 bool ShouldRedactChallenge(HttpAuthChallengeTokenizer* challenge) {
17 // 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
18 // 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.
19 if (challenge->challenge_text().find(',') != std::string::npos) 19 if (challenge->challenge_text().find(',') != std::string::npos)
20 return false; 20 return false;
21 21
22 std::string scheme = base::ToLowerASCII(challenge->scheme()); 22 std::string scheme = challenge->NormalizedScheme();
23 // Invalid input. 23 // Invalid input.
24 if (scheme.empty()) 24 if (scheme.empty())
25 return false; 25 return false;
26 26
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;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 if (redact_begin == redact_end) 67 if (redact_begin == redact_end)
68 return value; 68 return value;
69 69
70 return std::string(value.begin(), redact_begin) + 70 return std::string(value.begin(), redact_begin) +
71 base::StringPrintf("[%ld bytes were stripped]", 71 base::StringPrintf("[%ld bytes were stripped]",
72 static_cast<long>(redact_end - redact_begin)) + 72 static_cast<long>(redact_end - redact_begin)) +
73 std::string(redact_end, value.end()); 73 std::string(redact_end, value.end());
74 } 74 }
75 75
76 } // namespace net 76 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_unittest.cc ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698