summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-11 18:13:39 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-11 18:13:39 +0000
commitdbb83db9ae0c4f774b22dcfbcff5840954311952 (patch)
treee2bc73418af30add1336f701dbfdea76644bc772 /net
parent5101952f5cd5adeb5d1563c7506006a053e27346 (diff)
downloadchromium_src-dbb83db9ae0c4f774b22dcfbcff5840954311952.zip
chromium_src-dbb83db9ae0c4f774b22dcfbcff5840954311952.tar.gz
chromium_src-dbb83db9ae0c4f774b22dcfbcff5840954311952.tar.bz2
Add the response headers to net-internals.
BUG=43812 Review URL: http://codereview.chromium.org/2015011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46943 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/net_log_event_type_list.h15
-rw-r--r--net/http/http_network_transaction.cc40
-rw-r--r--net/http/http_network_transaction_unittest.cc16
3 files changed, 69 insertions, 2 deletions
diff --git a/net/base/net_log_event_type_list.h b/net/base/net_log_event_type_list.h
index 5d9e312..8fdcf80 100644
--- a/net/base/net_log_event_type_list.h
+++ b/net/base/net_log_event_type_list.h
@@ -321,6 +321,21 @@ EVENT_TYPE(HTTP_TRANSACTION_SEND_TUNNEL_HEADERS)
// Measures the time to read HTTP response headers from the server.
EVENT_TYPE(HTTP_TRANSACTION_READ_HEADERS)
+// This event is sent on receipt of the HTTP response headers.
+// The following parameters are attached:
+// {
+// "headers": <The list of header:value pairs>
+// }
+EVENT_TYPE(HTTP_TRANSACTION_READ_RESPONSE_HEADERS)
+
+// This event is sent on receipt of the HTTP response headers to a tunnel
+// request.
+// The following parameters are attached:
+// {
+// "headers": <The list of header:value pairs>
+// }
+EVENT_TYPE(HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS)
+
// Measures the time to resolve the canonical name for HTTP Negotiate
// authentication scheme.
EVENT_TYPE(HTTP_TRANSACTION_RESOLVE_CANONICAL_NAME)
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index acb16ca..34a0027 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -238,6 +238,34 @@ class NetLogHttpRequestParameter : public NetLog::EventParameters {
DISALLOW_COPY_AND_ASSIGN(NetLogHttpRequestParameter);
};
+class NetLogHttpResponseParameter : public NetLog::EventParameters {
+ public:
+ explicit NetLogHttpResponseParameter(
+ const scoped_refptr<HttpResponseHeaders>& headers)
+ : headers_(headers) {}
+
+ Value* ToValue() const {
+ DictionaryValue* dict = new DictionaryValue();
+ ListValue* headers = new ListValue();
+ void* iterator = NULL;
+ std::string name;
+ std::string value;
+ while (headers_->EnumerateHeaderLines(&iterator, &name, &value)) {
+ headers->Append(
+ new StringValue(StringPrintf("%s: %s", name.c_str(), value.c_str())));
+ }
+ dict->Set(L"headers", headers);
+ return dict;
+ }
+
+ private:
+ ~NetLogHttpResponseParameter() {}
+
+ const scoped_refptr<HttpResponseHeaders> headers_;
+
+ DISALLOW_COPY_AND_ASSIGN(NetLogHttpResponseParameter);
+};
+
} // namespace
//-----------------------------------------------------------------------------
@@ -1128,6 +1156,18 @@ int HttpNetworkTransaction::DoReadHeadersComplete(int result) {
return rv;
}
+ if (net_log_.HasListener()) {
+ if (establishing_tunnel_) {
+ net_log_.AddEvent(
+ NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS,
+ new NetLogHttpResponseParameter(response_.headers));
+ } else {
+ net_log_.AddEvent(
+ NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS,
+ new NetLogHttpResponseParameter(response_.headers));
+ }
+ }
+
if (response_.headers->GetParsedHttpVersion() < HttpVersion(1, 0)) {
// Require the "HTTP/1.x" status line for SSL CONNECT.
if (establishing_tunnel_)
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index 5d343eb..6581201 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -172,9 +172,13 @@ class HttpNetworkTransactionTest : public PlatformTest {
rv = ReadTransaction(trans.get(), &out.response_data);
EXPECT_EQ(OK, rv);
- ExpectLogContainsSomewhere(
+ size_t pos = ExpectLogContainsSomewhere(
log.entries(), 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS,
NetLog::PHASE_NONE);
+ ExpectLogContainsSomewhere(
+ log.entries(), pos,
+ NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS,
+ NetLog::PHASE_NONE);
return out;
}
@@ -1285,11 +1289,19 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthProxyKeepAlive) {
TestCompletionCallback callback1;
- int rv = trans->Start(&request, &callback1, BoundNetLog());
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ int rv = trans->Start(&request, &callback1, log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback1.WaitForResult();
EXPECT_EQ(OK, rv);
+ size_t pos = ExpectLogContainsSomewhere(
+ log.entries(), 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS,
+ NetLog::PHASE_NONE);
+ ExpectLogContainsSomewhere(
+ log.entries(), pos,
+ NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS,
+ NetLog::PHASE_NONE);
const HttpResponseInfo* response = trans->GetResponseInfo();
EXPECT_FALSE(response == NULL);