| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO(eroman): put these methods into a namespace. | 5 // TODO(eroman): put these methods into a namespace. |
| 6 | 6 |
| 7 var printLogEntriesAsText; | 7 var printLogEntriesAsText; |
| 8 var proxySettingsToString; | 8 var proxySettingsToString; |
| 9 var stripCookiesAndLoginInfo; | 9 var stripCookiesAndLoginInfo; |
| 10 | 10 |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 return match[0] + '[value was stripped]'; | 435 return match[0] + '[value was stripped]'; |
| 436 } | 436 } |
| 437 | 437 |
| 438 return line; | 438 return line; |
| 439 } | 439 } |
| 440 | 440 |
| 441 /** | 441 /** |
| 442 * If |entry| has headers, returns a copy of |entry| with all cookie and | 442 * If |entry| has headers, returns a copy of |entry| with all cookie and |
| 443 * unencrypted login text removed. Otherwise, returns original |entry| object. | 443 * unencrypted login text removed. Otherwise, returns original |entry| object. |
| 444 * This is needed so that JSON log dumps can be made without affecting the | 444 * This is needed so that JSON log dumps can be made without affecting the |
| 445 * source data. | 445 * source data. Also, if the input entry's headers are an object, the resulting |
| 446 * object will have its headers in a list. |
| 446 */ | 447 */ |
| 447 stripCookiesAndLoginInfo = function(entry) { | 448 stripCookiesAndLoginInfo = function(entry) { |
| 448 if (!entry.params || !entry.params.headers || | 449 if (!entry.params || !entry.params.headers) |
| 449 !(entry.params.headers instanceof Array)) { | |
| 450 return entry; | 450 return entry; |
| 451 var headers = entry.params.headers; |
| 452 if (!(headers instanceof Object) && !(headers instanceof Array)) |
| 453 return; |
| 454 |
| 455 if (headers instanceof Object) { |
| 456 headers = []; |
| 457 for (var key in entry.params.headers) |
| 458 headers.push(key + ': ' + entry.params.headers[key]); |
| 451 } | 459 } |
| 452 | 460 |
| 453 // Duplicate the top level object, and |entry.params|. All other fields are | 461 // Duplicate the top level object, and |entry.params|. All other fields are |
| 454 // just pointers to the original values, as they won't be modified, other than | 462 // just pointers to the original values, as they won't be modified, other than |
| 455 // |entry.params.headers|. | 463 // |entry.params.headers|. |
| 456 entry = shallowCloneObject(entry); | 464 entry = shallowCloneObject(entry); |
| 457 entry.params = shallowCloneObject(entry.params); | 465 entry.params = shallowCloneObject(entry.params); |
| 458 | 466 |
| 459 entry.params.headers = entry.params.headers.map(stripCookieOrLoginInfo); | 467 entry.params.headers = headers.map(stripCookieOrLoginInfo); |
| 460 return entry; | 468 return entry; |
| 461 } | 469 } |
| 462 | 470 |
| 463 /** | 471 /** |
| 464 * Outputs the request header parameters of |entry| to |out|. | 472 * Outputs the request header parameters of |entry| to |out|. |
| 465 */ | 473 */ |
| 466 function writeParamsForRequestHeaders(entry, out, consumedParams) { | 474 function writeParamsForRequestHeaders(entry, out, consumedParams) { |
| 467 var params = entry.params; | 475 var params = entry.params; |
| 468 | 476 |
| 469 if (!(typeof params.line == 'string') || !(params.headers instanceof Array)) { | 477 if (!(typeof params.line == 'string') || !(params.headers instanceof Array)) { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 | 636 |
| 629 if (config.source != undefined && config.source != 'UNKNOWN') | 637 if (config.source != undefined && config.source != 'UNKNOWN') |
| 630 result.push('Source: ' + config.source); | 638 result.push('Source: ' + config.source); |
| 631 | 639 |
| 632 return result.join('\n'); | 640 return result.join('\n'); |
| 633 }; | 641 }; |
| 634 | 642 |
| 635 // End of anonymous namespace. | 643 // End of anonymous namespace. |
| 636 })(); | 644 })(); |
| 637 | 645 |
| OLD | NEW |