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

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

Issue 149703005: Elide proxy authentication headers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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 | « no previous file | net/http/http_response_headers.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 (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 #include "net/http/http_request_headers.h" 5 #include "net/http/http_request_headers.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_split.h" 8 #include "base/strings/string_split.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "net/http/http_util.h" 12 #include "net/http/http_util.h"
13 13
14 namespace {
15
16 bool ShouldShowHttpHeaderValue(const std::string& header_name) {
17 #if defined(SPDY_PROXY_AUTH_ORIGIN)
18 if (header_name == "Proxy-Authorization")
19 return false;
20 #endif
21 return true;
22 }
23
24 } // namespace
25
14 namespace net { 26 namespace net {
15 27
16 const char HttpRequestHeaders::kGetMethod[] = "GET"; 28 const char HttpRequestHeaders::kGetMethod[] = "GET";
17 const char HttpRequestHeaders::kAcceptCharset[] = "Accept-Charset"; 29 const char HttpRequestHeaders::kAcceptCharset[] = "Accept-Charset";
18 const char HttpRequestHeaders::kAcceptEncoding[] = "Accept-Encoding"; 30 const char HttpRequestHeaders::kAcceptEncoding[] = "Accept-Encoding";
19 const char HttpRequestHeaders::kAcceptLanguage[] = "Accept-Language"; 31 const char HttpRequestHeaders::kAcceptLanguage[] = "Accept-Language";
20 const char HttpRequestHeaders::kAuthorization[] = "Authorization"; 32 const char HttpRequestHeaders::kAuthorization[] = "Authorization";
21 const char HttpRequestHeaders::kCacheControl[] = "Cache-Control"; 33 const char HttpRequestHeaders::kCacheControl[] = "Cache-Control";
22 const char HttpRequestHeaders::kConnection[] = "Connection"; 34 const char HttpRequestHeaders::kConnection[] = "Connection";
23 const char HttpRequestHeaders::kContentLength[] = "Content-Length"; 35 const char HttpRequestHeaders::kContentLength[] = "Content-Length";
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 196 }
185 197
186 base::Value* HttpRequestHeaders::NetLogCallback( 198 base::Value* HttpRequestHeaders::NetLogCallback(
187 const std::string* request_line, 199 const std::string* request_line,
188 NetLog::LogLevel /* log_level */) const { 200 NetLog::LogLevel /* log_level */) const {
189 base::DictionaryValue* dict = new base::DictionaryValue(); 201 base::DictionaryValue* dict = new base::DictionaryValue();
190 dict->SetString("line", *request_line); 202 dict->SetString("line", *request_line);
191 base::ListValue* headers = new base::ListValue(); 203 base::ListValue* headers = new base::ListValue();
192 for (HeaderVector::const_iterator it = headers_.begin(); 204 for (HeaderVector::const_iterator it = headers_.begin();
193 it != headers_.end(); ++it) { 205 it != headers_.end(); ++it) {
194 headers->Append( 206 headers->Append(new base::StringValue(
195 new base::StringValue(base::StringPrintf("%s: %s", 207 base::StringPrintf("%s: %s",
196 it->key.c_str(), 208 it->key.c_str(),
197 it->value.c_str()))); 209 (ShouldShowHttpHeaderValue(it->key) ?
210 it->value.c_str() : "[elided]"))));
198 } 211 }
199 dict->Set("headers", headers); 212 dict->Set("headers", headers);
200 return dict; 213 return dict;
201 } 214 }
202 215
203 // static 216 // static
204 bool HttpRequestHeaders::FromNetLogParam(const base::Value* event_param, 217 bool HttpRequestHeaders::FromNetLogParam(const base::Value* event_param,
205 HttpRequestHeaders* headers, 218 HttpRequestHeaders* headers,
206 std::string* request_line) { 219 std::string* request_line) {
207 headers->Clear(); 220 headers->Clear();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 it != headers_.end(); ++it) { 262 it != headers_.end(); ++it) {
250 if (key.length() == it->key.length() && 263 if (key.length() == it->key.length() &&
251 !base::strncasecmp(key.data(), it->key.data(), key.length())) 264 !base::strncasecmp(key.data(), it->key.data(), key.length()))
252 return it; 265 return it;
253 } 266 }
254 267
255 return headers_.end(); 268 return headers_.end();
256 } 269 }
257 270
258 } // namespace net 271 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_response_headers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698