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

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

Issue 10870080: Add SPDY request headers to DevTools. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Back to CL #6 Created 8 years, 3 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 | chrome/test/data/webui/net_internals/log_view_painter.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/net_internals/log_view_painter.js
===================================================================
--- chrome/browser/resources/net_internals/log_view_painter.js (revision 154321)
+++ chrome/browser/resources/net_internals/log_view_painter.js (working copy)
@@ -234,9 +234,13 @@
* default to a JSON-like format.
*/
function writeParameters(entry, privacyStripping, out) {
- // If privacy stripping is enabled, remove data as needed.
- if (privacyStripping)
+ if (privacyStripping) {
+ // If privacy stripping is enabled, remove data as needed.
entry = stripCookiesAndLoginInfo(entry);
+ } else {
+ // If headers are in an object, convert them to an array for better display.
+ entry = reformatHeaders(entry);
+ }
// Use any parameter writer available for this event type.
var paramsWriter = getParamaterWriterForEventType(entry.type);
@@ -388,6 +392,34 @@
}
/**
+ * If entry.param.headers exists and is an object other than an array, converts
+ * it into an array and returns a new entry. Otherwise, just returns the
+ * original entry.
+ */
+function reformatHeaders(entry) {
+ // If there are no headers, or it is not an object other than an array,
+ // return |entry| without modification.
+ if (!entry.params || entry.params.headers === undefined ||
+ typeof entry.params.headers != 'object' ||
+ entry.params.headers instanceof Array) {
+ return entry;
+ }
+
+ // Duplicate the top level object, and |entry.params|, so the original object
+ // will not be modified.
+ entry = shallowCloneObject(entry);
+ entry.params = shallowCloneObject(entry.params);
+
+ // Convert headers to an array.
+ var headers = [];
+ for (var key in entry.params.headers)
+ headers.push(key + ': ' + entry.params.headers[key]);
+ entry.params.headers = headers;
+
+ return entry;
+}
+
+/**
* Removes a cookie or unencrypted login information from a single HTTP header
* line, if present, and returns the modified line. Otherwise, just returns
* the original line.
@@ -442,14 +474,17 @@
* If |entry| has headers, returns a copy of |entry| with all cookie and
* unencrypted login text removed. Otherwise, returns original |entry| object.
* This is needed so that JSON log dumps can be made without affecting the
- * source data.
+ * source data. Converts headers stored in objects to arrays.
*/
stripCookiesAndLoginInfo = function(entry) {
- if (!entry.params || !entry.params.headers ||
- !(entry.params.headers instanceof Array)) {
+ if (!entry.params || entry.params.headers === undefined ||
+ !(entry.params.headers instanceof Object)) {
return entry;
}
+ // Make sure entry's headers are in an array.
+ entry = reformatHeaders(entry);
+
// Duplicate the top level object, and |entry.params|. All other fields are
// just pointers to the original values, as they won't be modified, other than
// |entry.params.headers|.
« no previous file with comments | « no previous file | chrome/test/data/webui/net_internals/log_view_painter.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698