Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Unified Diff: chrome/browser/resources/net_internals/logviewpainter.js

Issue 2025005: Add custom formatting for the HTTP request headers. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: do same for tunnel headers Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/net_internals/logviewpainter.js
===================================================================
--- chrome/browser/resources/net_internals/logviewpainter.js (revision 46870)
+++ chrome/browser/resources/net_internals/logviewpainter.js (working copy)
@@ -102,13 +102,43 @@
}
function getTextForExtraParams(entry) {
- var out = [];
- for (var k in entry.extra_parameters) {
- out.push(' --> ' + k + ' = ' + JSON.stringify(entry.extra_parameters[k]));
+ // 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);
+
+ default:
+ var out = [];
+ for (var k in entry.extra_parameters) {
+ out.push(' --> ' + k + ' = ' +
+ JSON.stringify(entry.extra_parameters[k]));
+ }
+ return out.join('\n');
}
- return out.join('\n');
}
+function getTextForRequestHeadersExtraParam(entry) {
+ var params = entry.extra_parameters;
+
+ // We prepend spaces to each line to make it line up with the arrow.
+ var firstLinePrefix = " --> "
+ var prefix = " ";
+
+ var out = [];
+
+ // Strip the trailing CRLF that params.line contains.
+ var lineWithoutCRLF = params.line.replace(/\r\n$/g, '');
+ out.push(firstLinePrefix + lineWithoutCRLF);
+
+ // Concatenate all of the header lines.
+ for (var i = 0; i < params.headers.length; ++i)
+ out.push(prefix + params.headers[i]);
+
+ return out.join("\n");
+}
+
function getTextForEvent(entry) {
var text = '';
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698