Commit 5000c113 authored by bengr@chromium.org's avatar bengr@chromium.org

Elide proxy authentication headers

The change prevent the data reduction proxy's authentication
headers from being exposed in net logs and dev tools.

BUG=179382

Review URL: https://codereview.chromium.org/149703005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248566 0039d316-1c4b-4281-b951-d872f2087c98
parent 6ab35fce
...@@ -11,6 +11,18 @@ ...@@ -11,6 +11,18 @@
#include "base/values.h" #include "base/values.h"
#include "net/http/http_util.h" #include "net/http/http_util.h"
namespace {
bool ShouldShowHttpHeaderValue(const std::string& header_name) {
#if defined(SPDY_PROXY_AUTH_ORIGIN)
if (header_name == "Proxy-Authorization")
return false;
#endif
return true;
}
} // namespace
namespace net { namespace net {
const char HttpRequestHeaders::kGetMethod[] = "GET"; const char HttpRequestHeaders::kGetMethod[] = "GET";
...@@ -191,10 +203,11 @@ base::Value* HttpRequestHeaders::NetLogCallback( ...@@ -191,10 +203,11 @@ base::Value* HttpRequestHeaders::NetLogCallback(
base::ListValue* headers = new base::ListValue(); base::ListValue* headers = new base::ListValue();
for (HeaderVector::const_iterator it = headers_.begin(); for (HeaderVector::const_iterator it = headers_.begin();
it != headers_.end(); ++it) { it != headers_.end(); ++it) {
headers->Append( headers->Append(new base::StringValue(
new base::StringValue(base::StringPrintf("%s: %s", base::StringPrintf("%s: %s",
it->key.c_str(), it->key.c_str(),
it->value.c_str()))); (ShouldShowHttpHeaderValue(it->key) ?
it->value.c_str() : "[elided]"))));
} }
dict->Set("headers", headers); dict->Set("headers", headers);
return dict; return dict;
......
...@@ -113,6 +113,14 @@ void CheckDoesNotHaveEmbededNulls(const std::string& str) { ...@@ -113,6 +113,14 @@ void CheckDoesNotHaveEmbededNulls(const std::string& str) {
CHECK(str.find('\0') == std::string::npos); CHECK(str.find('\0') == std::string::npos);
} }
bool ShouldShowHttpHeaderValue(const std::string& header_name) {
#if defined(SPDY_PROXY_AUTH_ORIGIN)
if (header_name == "Proxy-Authenticate")
return false;
#endif
return true;
}
} // namespace } // namespace
const char HttpResponseHeaders::kContentRange[] = "Content-Range"; const char HttpResponseHeaders::kContentRange[] = "Content-Range";
...@@ -1311,9 +1319,11 @@ base::Value* HttpResponseHeaders::NetLogCallback( ...@@ -1311,9 +1319,11 @@ base::Value* HttpResponseHeaders::NetLogCallback(
std::string value; std::string value;
while (EnumerateHeaderLines(&iterator, &name, &value)) { while (EnumerateHeaderLines(&iterator, &name, &value)) {
headers->Append( headers->Append(
new base::StringValue(base::StringPrintf("%s: %s", new base::StringValue(
name.c_str(), base::StringPrintf("%s: %s",
value.c_str()))); name.c_str(),
(ShouldShowHttpHeaderValue(name) ?
value.c_str() : "[elided]"))));
} }
dict->Set("headers", headers); dict->Set("headers", headers);
return dict; return dict;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment