| 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|.
|
|
|