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

Side by Side 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: Fix log view painter, add tests 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 return ParameterOutputter; 227 return ParameterOutputter;
228 })(); // end of ParameterOutputter 228 })(); // end of ParameterOutputter
229 229
230 /** 230 /**
231 * Formats the parameters for |entry| to |out| using a custom. 231 * Formats the parameters for |entry| to |out| using a custom.
232 * 232 *
233 * Certain event types will have custom pretty printers. Everything else will 233 * Certain event types will have custom pretty printers. Everything else will
234 * default to a JSON-like format. 234 * default to a JSON-like format.
235 */ 235 */
236 function writeParameters(entry, privacyStripping, out) { 236 function writeParameters(entry, privacyStripping, out) {
237 // If privacy stripping is enabled, remove data as needed. 237 if (privacyStripping) {
238 if (privacyStripping) 238 // If privacy stripping is enabled, remove data as needed.
239 entry = stripCookiesAndLoginInfo(entry); 239 entry = stripCookiesAndLoginInfo(entry);
240 } else {
241 // If headers an in an object, convert them to an array, for better display.
eroman 2012/09/05 21:44:32 typo: "headers an in"
mmenke 2012/09/06 17:26:33 Done.
242 entry = reformatHeaders(entry);
243 }
240 244
241 // Use any parameter writer available for this event type. 245 // Use any parameter writer available for this event type.
242 var paramsWriter = getParamaterWriterForEventType(entry.type); 246 var paramsWriter = getParamaterWriterForEventType(entry.type);
243 var consumedParams = {}; 247 var consumedParams = {};
244 if (paramsWriter) 248 if (paramsWriter)
245 paramsWriter(entry, out, consumedParams); 249 paramsWriter(entry, out, consumedParams);
246 250
247 // Write any un-consumed parameters. 251 // Write any un-consumed parameters.
248 for (var k in entry.params) { 252 for (var k in entry.params) {
249 if (consumedParams[k]) 253 if (consumedParams[k])
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 * 385 *
382 * " -> line1\n" + 386 * " -> line1\n" +
383 * " line2\n" + 387 * " line2\n" +
384 * " line3" 388 * " line3"
385 */ 389 */
386 function indentLines(start, lines) { 390 function indentLines(start, lines) {
387 return start + lines.join('\n' + makeRepeatedString(' ', start.length)); 391 return start + lines.join('\n' + makeRepeatedString(' ', start.length));
388 } 392 }
389 393
390 /** 394 /**
395 * If entry.param.headers exists and is an object other than an Array, converts
396 * it into an Array, and returns a new entry. Otherwise, just returns the
397 * original entry.
398 */
399 function reformatHeaders(entry) {
400 // If there are no headers, or it is not an object other than an array,
401 // return |entry| without modification.
402 if (!entry.params || entry.params.headers === undefined ||
403 typeof entry.params.headers != 'object' ||
404 entry.params.headers instanceof Array) {
405 return entry;
406 }
407
408 // Duplicate the top level object, and |entry.params|, so the original object
409 // will not be modified.
410 entry = shallowCloneObject(entry);
411 entry.params = shallowCloneObject(entry.params);
412
413 // Convert headers to an array.
414 var headers = [];
415 for (var key in entry.params.headers)
416 headers.push(key + ': ' + entry.params.headers[key]);
417 entry.params.headers = headers;
418
419 return entry;
420 }
421
422 /**
391 * Removes a cookie or unencrypted login information from a single HTTP header 423 * Removes a cookie or unencrypted login information from a single HTTP header
392 * line, if present, and returns the modified line. Otherwise, just returns 424 * line, if present, and returns the modified line. Otherwise, just returns
393 * the original line. 425 * the original line.
394 */ 426 */
395 function stripCookieOrLoginInfo(line) { 427 function stripCookieOrLoginInfo(line) {
396 var patterns = [ 428 var patterns = [
397 // Cookie patterns 429 // Cookie patterns
398 /^set-cookie:/i, 430 /^set-cookie:/i,
399 /^set-cookie2:/i, 431 /^set-cookie2:/i,
400 /^cookie:/i, 432 /^cookie:/i,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 return match[0] + '[value was stripped]'; 467 return match[0] + '[value was stripped]';
436 } 468 }
437 469
438 return line; 470 return line;
439 } 471 }
440 472
441 /** 473 /**
442 * If |entry| has headers, returns a copy of |entry| with all cookie and 474 * If |entry| has headers, returns a copy of |entry| with all cookie and
443 * unencrypted login text removed. Otherwise, returns original |entry| object. 475 * unencrypted login text removed. Otherwise, returns original |entry| object.
444 * This is needed so that JSON log dumps can be made without affecting the 476 * This is needed so that JSON log dumps can be made without affecting the
445 * source data. 477 * source data. Converts headers stored in objects to arrays.
446 */ 478 */
447 stripCookiesAndLoginInfo = function(entry) { 479 stripCookiesAndLoginInfo = function(entry) {
448 if (!entry.params || !entry.params.headers || 480 if (!entry.params || entry.params.headers === undefined ||
449 !(entry.params.headers instanceof Array)) { 481 !(entry.params.headers instanceof Object)) {
450 return entry; 482 return entry;
451 } 483 }
452 484
485 // Make sure entry's headers are in an array.
486 entry = reformatHeaders(entry);
487
453 // Duplicate the top level object, and |entry.params|. All other fields are 488 // 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 489 // just pointers to the original values, as they won't be modified, other than
455 // |entry.params.headers|. 490 // |entry.params.headers|.
456 entry = shallowCloneObject(entry); 491 entry = shallowCloneObject(entry);
457 entry.params = shallowCloneObject(entry.params); 492 entry.params = shallowCloneObject(entry.params);
458 493
459 entry.params.headers = entry.params.headers.map(stripCookieOrLoginInfo); 494 entry.params.headers = entry.params.headers.map(stripCookieOrLoginInfo);
460 return entry; 495 return entry;
461 } 496 }
462 497
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 663
629 if (config.source != undefined && config.source != 'UNKNOWN') 664 if (config.source != undefined && config.source != 'UNKNOWN')
630 result.push('Source: ' + config.source); 665 result.push('Source: ' + config.source);
631 666
632 return result.join('\n'); 667 return result.join('\n');
633 }; 668 };
634 669
635 // End of anonymous namespace. 670 // End of anonymous namespace.
636 })(); 671 })();
637 672
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/webui/net_internals/log_view_painter.js » ('j') | net/spdy/spdy_header_block.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698