summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-04 18:14:15 +0000
committercbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-04 18:14:15 +0000
commit815d63d9f1c68ffa056ad2c2c8fee34f0d0b70b8 (patch)
tree21a4f80d542cc40f09576ca16010b22bf6e8884e
parenta4bb001e1a5a666b10f27d4c2b3c1f24c715306e (diff)
downloadchromium_src-815d63d9f1c68ffa056ad2c2c8fee34f0d0b70b8.zip
chromium_src-815d63d9f1c68ffa056ad2c2c8fee34f0d0b70b8.tar.gz
chromium_src-815d63d9f1c68ffa056ad2c2c8fee34f0d0b70b8.tar.bz2
Adds an option, enabled by default, to net-internals to
remove cookies from log dumps. Also, SPDY headers are now displayed (And stored) just like http ones. Cookies are always shown on the Requests page. As an added bonus, removes a superfluous </b> from index.html. Contributed by: mmenke@google.com BUG= 50668 TEST= Go to about:net-internals, and check for properly hiding cookies for both HTTP and SPDY, for both sent and received cookies. Review URL: http://codereview.chromium.org/3072013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54932 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/net_internals/dataview.js7
-rw-r--r--chrome/browser/resources/net_internals/index.html7
-rw-r--r--chrome/browser/resources/net_internals/logviewpainter.js45
-rw-r--r--chrome/browser/resources/net_internals/main.js2
-rw-r--r--net/spdy/spdy_session.cc8
5 files changed, 51 insertions, 18 deletions
diff --git a/chrome/browser/resources/net_internals/dataview.js b/chrome/browser/resources/net_internals/dataview.js
index 4a69b89..4a1ce73 100644
--- a/chrome/browser/resources/net_internals/dataview.js
+++ b/chrome/browser/resources/net_internals/dataview.js
@@ -12,10 +12,12 @@
*
* @constructor
*/
-function DataView(mainBoxId, outputTextBoxId, exportTextButtonId) {
+function DataView(mainBoxId, outputTextBoxId, exportTextButtonId,
+ stripCookiesCheckboxId) {
DivView.call(this, mainBoxId);
this.textPre_ = document.getElementById(outputTextBoxId);
+ this.stripCookiesCheckbox_ = document.getElementById(stripCookiesCheckboxId);
var exportTextButton = document.getElementById(exportTextButtonId);
exportTextButton.onclick = this.onExportToText_.bind(this);
@@ -182,7 +184,8 @@ DataView.prototype.appendRequestsPrintedAsText_ = function(out) {
' [start=' + startDate.toLocaleString() + ']');
out.push('------------------------------------------');
- out.push(PrintSourceEntriesAsText(eventList));
+ out.push(PrintSourceEntriesAsText(eventList,
+ this.stripCookiesCheckbox_.checked));
}
};
diff --git a/chrome/browser/resources/net_internals/index.html b/chrome/browser/resources/net_internals/index.html
index 14e4697..be73f52 100644
--- a/chrome/browser/resources/net_internals/index.html
+++ b/chrome/browser/resources/net_internals/index.html
@@ -104,7 +104,8 @@ found in the LICENSE file.
<ol>
<li>Reproduce the network problem.</li>
<li>Click this button:
- <button id=exportToText style="font-size: 110%"><b>Dump to text</b> </button>
+ <button id=exportToText style="font-size: 110%"><b>Dump to text</b> </button><br>
+ (<input id=stripCookiesCheckbox type=checkbox checked=yes> Remove cookies)
</li>
<li>Copy-paste the data on this page to a text file.</li>
@@ -136,6 +137,8 @@ function toggleMoreExplanation() {
<ul>
<li>You can edit the log to obscure information if you like, but sometimes it
is relevant to the bug.</li>
+<li>If you choose not to have cookies removed from the log, you must toggle
+ the checkbox before clicking the button.</li>
</ul>
<li>Ideally you would have this tool running <b>before</b> you reproduce the
bug.
@@ -154,7 +157,7 @@ function toggleMoreExplanation() {
<li>Chrome keeps around a small buffer of network events for the
<b>most recent</b> requests. That way if you open chrome://net-internals/
<b>shortly after</b> encountering a problem, you can still find the relevant
- data. </b>
+ data.
These <b>passively captured</b> events are less accurate however, and will
be prefixed in the log with <span style="font-family: monospace;">(P)</span>.
</li>
diff --git a/chrome/browser/resources/net_internals/logviewpainter.js b/chrome/browser/resources/net_internals/logviewpainter.js
index 6271cdd..f8152f2 100644
--- a/chrome/browser/resources/net_internals/logviewpainter.js
+++ b/chrome/browser/resources/net_internals/logviewpainter.js
@@ -41,7 +41,7 @@ function addSourceEntry_(node, sourceEntry) {
addTextNode(nobr2, 'Start Time: ' + startDate.toLocaleString());
var pre = addNode(div, 'pre');
- addTextNode(pre, PrintSourceEntriesAsText(logEntries));
+ addTextNode(pre, PrintSourceEntriesAsText(logEntries, false));
}
function canCollapseBeginWithEnd(beginEntry) {
@@ -55,7 +55,7 @@ function canCollapseBeginWithEnd(beginEntry) {
beginEntry.end.orig.wasPassivelyCaptured;
}
-PrintSourceEntriesAsText = function(sourceEntries) {
+PrintSourceEntriesAsText = function(sourceEntries, doStripCookies) {
var entries = LogGroupEntry.createArrayFrom(sourceEntries);
if (entries.length == 0)
return '';
@@ -110,7 +110,7 @@ PrintSourceEntriesAsText = function(sourceEntries) {
// Output the extra parameters.
if (entry.orig.params != undefined) {
// Add a continuation row for each line of text from the extra parameters.
- var extraParamsText = getTextForExtraParams(entry.orig);
+ var extraParamsText = getTextForExtraParams(entry.orig, doStripCookies);
var extraParamsTextLines = extraParamsText.split('\n');
for (var j = 0; j < extraParamsTextLines.length; ++j) {
@@ -133,21 +133,25 @@ PrintSourceEntriesAsText = function(sourceEntries) {
return tablePrinter.toText();
}
-function getTextForExtraParams(entry) {
+function getTextForExtraParams(entry, doStripCookies) {
// Format the extra parameters (use a custom formatter for certain types,
// but default to displaying as JSON).
switch (entry.type) {
case LogEventType.HTTP_TRANSACTION_SEND_REQUEST_HEADERS:
case LogEventType.HTTP_TRANSACTION_SEND_TUNNEL_HEADERS:
- return getTextForRequestHeadersExtraParam(entry);
+ return getTextForRequestHeadersExtraParam(entry, doStripCookies);
case LogEventType.HTTP_TRANSACTION_READ_RESPONSE_HEADERS:
case LogEventType.HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS:
- return getTextForResponseHeadersExtraParam(entry);
+ return getTextForResponseHeadersExtraParam(entry, doStripCookies);
default:
var out = [];
for (var k in entry.params) {
+ if (k == 'headers' && entry.params[k] instanceof Array) {
+ out.push(getTextForResponseHeadersExtraParam(entry, doStripCookies));
+ continue;
+ }
var value = entry.params[k];
var paramStr = ' --> ' + k + ' = ' + JSON.stringify(value);
@@ -211,17 +215,38 @@ function indentLines(start, lines) {
return start + lines.join('\n' + makeRepeatedString(' ', start.length));
}
-function getTextForRequestHeadersExtraParam(entry) {
+function stripCookie(line) {
+ var patterns = [/^set-cookie:/i, /^set-cookie2:/i, /^cookie:/i];
+ for (var i = 0; i < patterns.length; i++) {
+ var match = patterns[i].exec(line);
+ if (match != null)
+ return match + " [value was stripped]";
+ }
+ return line;
+}
+
+function stripCookies(headers) {
+ return headers.map(stripCookie);
+}
+
+function getTextForRequestHeadersExtraParam(entry, doStripCookies) {
var params = entry.params;
// Strip the trailing CRLF that params.line contains.
var lineWithoutCRLF = params.line.replace(/\r\n$/g, '');
- return indentLines(' --> ', [lineWithoutCRLF].concat(params.headers));
+ var headers = params.headers;
+ if (doStripCookies)
+ headers = stripCookies(headers);
+
+ return indentLines(' --> ', [lineWithoutCRLF].concat(headers));
}
-function getTextForResponseHeadersExtraParam(entry) {
- return indentLines(' --> ', entry.params.headers);
+function getTextForResponseHeadersExtraParam(entry, doStripCookies) {
+ var headers = entry.params.headers;
+ if (doStripCookies)
+ headers = stripCookies(headers);
+ return indentLines(' --> ', headers);
}
function getTextForEvent(entry) {
diff --git a/chrome/browser/resources/net_internals/main.js b/chrome/browser/resources/net_internals/main.js
index d0428fe..38b708a 100644
--- a/chrome/browser/resources/net_internals/main.js
+++ b/chrome/browser/resources/net_internals/main.js
@@ -63,7 +63,7 @@ function onLoaded() {
// Create a view which will display import/export options to control the
// captured data.
var dataView = new DataView("dataTabContent", "exportedDataText",
- "exportToText");
+ "exportToText", "stripCookiesCheckbox");
// Create a view which will display the results and controls for connection
// tests.
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 46e2273..1df0afa 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -84,13 +84,15 @@ class NetLogSpdySynParameter : public NetLog::EventParameters {
Value* ToValue() const {
DictionaryValue* dict = new DictionaryValue();
- DictionaryValue* headers_dict = new DictionaryValue();
+ ListValue* headers_list = new ListValue();
for (spdy::SpdyHeaderBlock::const_iterator it = headers_->begin();
it != headers_->end(); ++it) {
- headers_dict->SetString(it->first, it->second);
+ headers_list->Append(new StringValue(StringPrintf("%s: %s",
+ it->first.c_str(),
+ it->second.c_str())));
}
dict->SetInteger("flags", flags_);
- dict->Set("headers", headers_dict);
+ dict->Set("headers", headers_list);
dict->SetInteger("id", id_);
return dict;
}