summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbengr@chromium.org <bengr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-06 04:25:16 +0000
committerbengr@chromium.org <bengr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-06 04:25:16 +0000
commit556b271692e038297a05c32dbf2bf1838400809f (patch)
treee508ab32e40976d1e78bd3355ab2ac547b2aa97b
parent1d01807e2f36c8700d2b81f10ddfb0acbde2873c (diff)
downloadchromium_src-556b271692e038297a05c32dbf2bf1838400809f.zip
chromium_src-556b271692e038297a05c32dbf2bf1838400809f.tar.gz
chromium_src-556b271692e038297a05c32dbf2bf1838400809f.tar.bz2
Cleaned up code to update listing of headers
BUG=179382 Review URL: https://chromiumcodereview.appspot.com/12393058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186357 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/spdy/spdy_header_block.cc15
-rw-r--r--net/spdy/spdy_http_utils.cc8
-rw-r--r--net/spdy/spdy_http_utils.h4
-rw-r--r--net/spdy/spdy_http_utils_unittest.cc10
-rw-r--r--net/spdy/spdy_session.cc15
5 files changed, 29 insertions, 23 deletions
diff --git a/net/spdy/spdy_header_block.cc b/net/spdy/spdy_header_block.cc
index acdbdde..c84753a 100644
--- a/net/spdy/spdy_header_block.cc
+++ b/net/spdy/spdy_header_block.cc
@@ -5,6 +5,7 @@
#include "net/spdy/spdy_header_block.h"
#include "base/values.h"
+#include "net/spdy/spdy_http_utils.h"
namespace net {
@@ -15,18 +16,10 @@ Value* SpdyHeaderBlockNetLogCallback(
DictionaryValue* headers_dict = new DictionaryValue();
for (SpdyHeaderBlock::const_iterator it = headers->begin();
it != headers->end(); ++it) {
-#if defined(OS_ANDROID)
- if (it->first == "proxy-authorization") {
headers_dict->SetWithoutPathExpansion(
- it->first, new StringValue("[elided]"));
- } else {
- headers_dict->SetWithoutPathExpansion(
- it->first, new StringValue(it->second));
- }
-#else
- headers_dict->SetWithoutPathExpansion(
- it->first, new StringValue(it->second));
-#endif
+ it->first,
+ new StringValue(
+ ShouldShowHttpHeaderValue(it->first) ? it->second : "[elided]"));
}
dict->Set("headers", headers_dict);
return dict;
diff --git a/net/spdy/spdy_http_utils.cc b/net/spdy/spdy_http_utils.cc
index 8a51685..edb8f1b 100644
--- a/net/spdy/spdy_http_utils.cc
+++ b/net/spdy/spdy_http_utils.cc
@@ -183,4 +183,12 @@ GURL GetUrlFromHeaderBlock(const SpdyHeaderBlock& headers,
return GURL(url);
}
+bool ShouldShowHttpHeaderValue(const std::string& header_name) {
+#if defined(SPDY_PROXY_AUTH_ORIGIN)
+ if (header_name == "proxy-authorization")
+ return false;
+#endif
+ return true;
+}
+
} // namespace net
diff --git a/net/spdy/spdy_http_utils.h b/net/spdy/spdy_http_utils.h
index 27b03ed..9f1e9e3 100644
--- a/net/spdy/spdy_http_utils.h
+++ b/net/spdy/spdy_http_utils.h
@@ -41,6 +41,10 @@ GURL GetUrlFromHeaderBlock(const SpdyHeaderBlock& headers,
int protocol_version,
bool pushed);
+// Returns true if the value of this header should be displayed.
+NET_EXPORT_PRIVATE bool ShouldShowHttpHeaderValue(
+ const std::string& header_name);
+
NET_EXPORT_PRIVATE SpdyPriority ConvertRequestPriorityToSpdyPriority(
RequestPriority priority,
int protocol_version);
diff --git a/net/spdy/spdy_http_utils_unittest.cc b/net/spdy/spdy_http_utils_unittest.cc
index 2419de1..5e299a9 100644
--- a/net/spdy/spdy_http_utils_unittest.cc
+++ b/net/spdy/spdy_http_utils_unittest.cc
@@ -25,6 +25,16 @@ TEST(SpdyHttpUtilsTest, ConvertRequestPriorityToSpdy3Priority) {
EXPECT_EQ(4, ConvertRequestPriorityToSpdyPriority(IDLE, 3));
}
+TEST(SpdyHttpUtilsTest, ShowHttpHeaderValue){
+#if defined(SPDY_PROXY_AUTH_ORIGIN)
+ EXPECT_FALSE(ShouldShowHttpHeaderValue("proxy-authorization"));
+ EXPECT_TRUE(ShouldShowHttpHeaderValue("accept-encoding"));
+#else
+ EXPECT_TRUE(ShouldShowHttpHeaderValue("proxy-authorization"));
+ EXPECT_TRUE(ShouldShowHttpHeaderValue("accept-encoding"));
+#endif
+}
+
} // namespace test
} // namespace net
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 6f7d9ca..6c154e7 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -62,19 +62,10 @@ base::Value* NetLogSpdySynCallback(const SpdyHeaderBlock* headers,
base::ListValue* headers_list = new base::ListValue();
for (SpdyHeaderBlock::const_iterator it = headers->begin();
it != headers->end(); ++it) {
-#if defined(OS_ANDROID)
- if (it->first == "proxy-authorization") {
- headers_list->Append(new base::StringValue(base::StringPrintf(
- "%s: %s", it->first.c_str(), "[elided]")));
- } else {
- headers_list->Append(new base::StringValue(base::StringPrintf(
- "%s: %s", it->first.c_str(), it->second.c_str())));
- }
-#else
headers_list->Append(new base::StringValue(base::StringPrintf(
- "%s: %s", it->first.c_str(), it->second.c_str())));
-#endif
-
+ "%s: %s", it->first.c_str(),
+ (ShouldShowHttpHeaderValue(
+ it->first) ? it->second : "[elided]").c_str())));
}
dict->SetBoolean("fin", fin);
dict->SetBoolean("unidirectional", unidirectional);