Skip to content

Commit af2caf8

Browse files
author
Daniel Herzog
committed
Fixed multipart display
1 parent 9702d99 commit af2caf8

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

src/network/network_details_templates.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ window.templates.network || (window.templates.network = {});
66
(function(templates) {
77

88
var HTTP_BOUNDARY_CLASS = "http-token-type-boundary";
9+
var UI_CLASSNAME = "not-content";
910
var TEXT_TYPES = ["markup", "script", "css", "text"];
1011

1112
templates._pre = function(content)
@@ -341,27 +342,30 @@ templates._request_body = function(req, do_raw)
341342
var ret; // todo: might revisit "ret", maybe return more often so that it's clear nothing more happens.
342343
if (req.request_body.partList.length) // Multipart
343344
{
344-
var multi_p_template = [];
345345
var use_raw_boundary = Boolean(do_raw && req.boundary);
346-
var boundary = use_raw_boundary ? ["span", req.boundary, "class", HTTP_BOUNDARY_CLASS] : ["hr"];
346+
var multi_p_template = [];
347347
for (var n = 0, part; part = req.request_body.partList[n]; n++)
348348
{
349-
if (n === 0)
350-
multi_p_template.push(boundary);
349+
if (use_raw_boundary && n === 0)
350+
multi_p_template.push(["span", req.boundary, "class", HTTP_BOUNDARY_CLASS]);
351351

352+
multi_p_template.push(["span", "\n"]);
352353
multi_p_template.extend(part.headerList.map(this._headers_pseudo_raw));
353-
multi_p_template.push(this._pre("\n"));
354+
multi_p_template.push(["span", "\n"]);
354355
if (part.content && part.content.stringData)
355356
multi_p_template.push(part.content.stringData);
356357
else
357-
multi_p_template.push(["p", ui_strings.S_NETWORK_N_BYTE_BODY.replace("%s", part.contentLength)]);
358+
multi_p_template.push(["span", ui_strings.S_NETWORK_N_BYTE_BODY.replace("%s", part.contentLength),
359+
"class", UI_CLASSNAME]);
358360

361+
var raw_boundary = req.boundary;
359362
if (use_raw_boundary && part === req.request_body.partList.last)
360-
{
361-
var TEXTCONTENT = 1;
362-
boundary[TEXTCONTENT] += "--\n";
363-
}
364-
multi_p_template.push(boundary);
363+
raw_boundary += "--";
364+
365+
if (use_raw_boundary)
366+
multi_p_template.push(["span", "\n" + raw_boundary, "class", HTTP_BOUNDARY_CLASS]);
367+
else
368+
multi_p_template.push(["hr"]);
365369
}
366370
ret = multi_p_template;
367371
}
@@ -378,8 +382,8 @@ templates._request_body = function(req, do_raw)
378382
var rows = [];
379383
rows.push([
380384
"tr",
381-
["th", ["p", ui_strings.S_LABEL_NETWORK_POST_DATA_NAME]],
382-
["th", ["p", ui_strings.S_LABEL_NETWORK_POST_DATA_VALUE]]
385+
["th", ["span", ui_strings.S_LABEL_NETWORK_POST_DATA_NAME, "class", UI_CLASSNAME]],
386+
["th", ["span", ui_strings.S_LABEL_NETWORK_POST_DATA_VALUE, "class", UI_CLASSNAME]]
383387
]
384388
);
385389
rows.extend(parts.map(this.param_cells));
@@ -401,11 +405,13 @@ templates._request_body = function(req, do_raw)
401405
{
402406
if (req.request_body.mimeType)
403407
{
404-
ret = ["p", ui_strings.S_NETWORK_CANT_DISPLAY_TYPE.replace("%s", req.request_body.mimeType)];
408+
ret = ["span", ui_strings.S_NETWORK_CANT_DISPLAY_TYPE.replace("%s", req.request_body.mimeType),
409+
"class", UI_CLASSNAME];
405410
}
406411
else
407412
{
408-
ret = ["p", ui_strings.S_NETWORK_UNKNOWN_MIME_TYPE];
413+
ret = ["span", ui_strings.S_NETWORK_UNKNOWN_MIME_TYPE,
414+
"class", UI_CLASSNAME];
409415
}
410416
}
411417
}
@@ -461,7 +467,8 @@ templates._response_body = function(resp, do_raw, is_last_response)
461467
else
462468
{
463469
ret.push(
464-
["p", ui_strings.S_NETWORK_REQUEST_DETAIL_UNDISPLAYABLE_BODY_LABEL.replace("%s", resp.logger_entry_mime)]
470+
["span", ui_strings.S_NETWORK_REQUEST_DETAIL_UNDISPLAYABLE_BODY_LABEL.replace("%s", resp.logger_entry_mime),
471+
"class", UI_CLASSNAME]
465472
);
466473
}
467474
}

0 commit comments

Comments
 (0)