Fix onBeforeSendHeaders regression: we were sending {name: name} for every

header value pair.

BUG=82137
TEST=no

Review URL: http://codereview.chromium.org/7048010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86308 0039d316-1c4b-4281-b951-d872f2087c98
parent 74835d79
...@@ -161,7 +161,7 @@ ListValue* GetRequestHeadersList(const net::HttpRequestHeaders* headers) { ...@@ -161,7 +161,7 @@ ListValue* GetRequestHeadersList(const net::HttpRequestHeaders* headers) {
for (net::HttpRequestHeaders::Iterator it(*headers); it.GetNext(); ) { for (net::HttpRequestHeaders::Iterator it(*headers); it.GetNext(); ) {
DictionaryValue* header = new DictionaryValue(); DictionaryValue* header = new DictionaryValue();
header->SetString(keys::kHeaderNameKey, it.name()); header->SetString(keys::kHeaderNameKey, it.name());
header->SetString(keys::kHeaderValueKey, it.name()); header->SetString(keys::kHeaderValueKey, it.value());
headers_value->Append(header); headers_value->Append(header);
} }
} }
......
...@@ -104,6 +104,16 @@ function checkExpectations() { ...@@ -104,6 +104,16 @@ function checkExpectations() {
eventsCaptured(); eventsCaptured();
} }
// Simple check to see that we have a User-Agent header, and that it contains
// an expected value. This is a basic check that the request headers are valid.
function checkUserAgent(headers) {
for (var i in headers) {
if (headers[i].name.toLowerCase() == "user-agent")
return headers[i].value.toLowerCase().indexOf("chrome") != -1;
}
return false;
}
function captureEvent(name, details) { function captureEvent(name, details) {
// Ignore system-level requests like safebrowsing updates and favicon fetches // Ignore system-level requests like safebrowsing updates and favicon fetches
// since they are unpredictable. // since they are unpredictable.
...@@ -123,7 +133,7 @@ function captureEvent(name, details) { ...@@ -123,7 +133,7 @@ function captureEvent(name, details) {
delete details.requestId; delete details.requestId;
delete details.timeStamp; delete details.timeStamp;
if (details.requestHeaders) { if (details.requestHeaders) {
details.requestHeadersExist = true; details.requestHeadersValid = checkUserAgent(details.requestHeaders);
delete details.requestHeaders; delete details.requestHeaders;
} }
if (details.responseHeaders) { if (details.responseHeaders) {
...@@ -263,7 +273,7 @@ runTests([ ...@@ -263,7 +273,7 @@ runTests([
event: "onBeforeSendHeaders", event: "onBeforeSendHeaders",
details: { details: {
url: URL_HTTP_SIMPLE_LOAD_REDIRECT, url: URL_HTTP_SIMPLE_LOAD_REDIRECT,
requestHeadersExist: true requestHeadersValid: true
} }
}, },
{ label: "onRequestSent-1", { label: "onRequestSent-1",
...@@ -271,7 +281,7 @@ runTests([ ...@@ -271,7 +281,7 @@ runTests([
details: { details: {
url: URL_HTTP_SIMPLE_LOAD_REDIRECT, url: URL_HTTP_SIMPLE_LOAD_REDIRECT,
ip: "127.0.0.1", ip: "127.0.0.1",
requestHeadersExist: true requestHeadersValid: true
} }
}, },
{ label: "onBeforeRedirect", { label: "onBeforeRedirect",
...@@ -297,7 +307,7 @@ runTests([ ...@@ -297,7 +307,7 @@ runTests([
event: "onBeforeSendHeaders", event: "onBeforeSendHeaders",
details: { details: {
url: URL_HTTP_SIMPLE_LOAD, url: URL_HTTP_SIMPLE_LOAD,
requestHeadersExist: true requestHeadersValid: true
} }
}, },
{ label: "onRequestSent-2", { label: "onRequestSent-2",
...@@ -305,7 +315,7 @@ runTests([ ...@@ -305,7 +315,7 @@ runTests([
details: { details: {
url: URL_HTTP_SIMPLE_LOAD, url: URL_HTTP_SIMPLE_LOAD,
ip: "127.0.0.1", ip: "127.0.0.1",
requestHeadersExist: true requestHeadersValid: true
} }
}, },
{ label: "onResponseStarted", { label: "onResponseStarted",
......
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