Skip to content

Commit a0d5bcb

Browse files
author
Daniel Herzog
committed
Added raw view for multipart requests; Some fixes
1 parent 8fc37e0 commit a0d5bcb

File tree

4 files changed

+43
-15
lines changed

4 files changed

+43
-15
lines changed

src/network/network_details_templates.js

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ templates._detail_row = function(wrap)
1515
return ["tr", ["td", wrap, "colspan", "2"]];
1616
};
1717

18+
templates.wrap_pre = function(str)
19+
{
20+
return ["pre", str, "class", "mono"];
21+
};
22+
1823
templates.details = function(entry, left_val, do_raw)
1924
{
2025
return (
@@ -191,11 +196,25 @@ templates._response_headers = function(resp, do_raw)
191196
return ["tbody", ret.map(templates._detail_row)];
192197
};
193198

194-
templates.headers_list = function(headers, firstline)
199+
templates.headers_list = function(headers, firstline, do_raw)
195200
{
196-
var lis = headers.map(function(header) {
201+
var map;
202+
if (do_raw) // todo: when raw, this is currently just for headers of parts in mutipart. should be used for others too, to gain the speclinks.
203+
{
204+
map = function(header)
205+
{
206+
return templates.wrap_pre([["span", header.name + ":", "data-spec", "http#" + header.name], ["span", " " + header.value]]);
207+
};
208+
}
209+
else
210+
{
211+
map = function(header)
212+
{
197213
return [["th", header.name + ":", "data-spec", "http#" + header.name], ["td", header.value]];
198-
});
214+
};
215+
}
216+
217+
var lis = headers.map(map);
199218

200219
if (firstline)
201220
{
@@ -204,36 +223,41 @@ templates.headers_list = function(headers, firstline)
204223
return lis;
205224
};
206225

207-
templates.body_separator = function()
208-
{
209-
return ["pre", " ", "class", "mono"];
210-
};
211-
212226
templates._request_body = function(req, do_raw)
213227
{
214228
if (req.requestbody == null)
215229
return [];
216230

217-
var ret = [templates.body_separator()];
231+
var ret = [templates.wrap_pre("\n")];
218232
if (req.requestbody.partList.length) // multipart
219233
{
234+
var use_raw_boundary = false;
235+
if (do_raw && req.boundary)
236+
use_raw_boundary = true;
237+
220238
for (var n = 0, part; part = req.requestbody.partList[n]; n++)
221239
{
222-
ret.concat(templates.headers_list(part.headerList));
240+
if (use_raw_boundary && n === 0)
241+
ret.push(this.wrap_pre(req.boundary));
242+
243+
ret.extend(templates.headers_list(part.headerList, null, do_raw));
244+
ret.push(this.wrap_pre("\n"));
223245
if (part.content && part.content.stringData)
224-
ret.push(["pre", part.content.stringData, "class", "mono"]);
246+
ret.push(["pre", part.content.stringData, "class", "mono network-body"]);
225247
else
226248
ret.push(["p", ui_strings.S_NETWORK_N_BYTE_BODY.replace("%s", part.contentLength)]);
227249

228250
if (n < req.requestbody.partList.length - 1)
229-
ret.push(["hr"]); // todo: when raw, use the boundary here
251+
ret.push(use_raw_boundary ? this.wrap_pre(req.boundary) : ["hr"]);
252+
else if (use_raw_boundary)
253+
ret.push(this.wrap_pre(req.boundary + "--\n"));
230254
}
231255
}
232256
else if (req.requestbody.mimeType.startswith("application/x-www-form-urlencoded"))
233257
{
234258
if (do_raw)
235259
{
236-
ret.push(["pre", req.requestbody.content.stringData]);
260+
ret.push(["pre", req.requestbody.content.stringData, "class", "mono network-body"]);
237261
}
238262
else
239263
{
@@ -284,7 +308,7 @@ templates._request_body = function(req, do_raw)
284308

285309
templates._response_body = function(resp, do_raw, is_last)
286310
{
287-
var ret = [templates.body_separator()]; // todo: no, then it's (really) empty there shouldn't be a separator either.
311+
var ret = [templates.wrap_pre("\n")]; // todo: no, then it's (really) empty there shouldn't be a separator either.
288312

289313
var classname = "";
290314
if (resp.body_unavailable ||

src/network/network_service.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,7 @@ cls.NetworkLoggerRequest = function(entry)
918918
this.request_type = null;
919919
this.firstline = null;
920920
this.requestbody = null;
921+
this.boundary = "";
921922
};
922923

923924
cls.NetworkLoggerRequestPrototype = function()
@@ -936,13 +937,15 @@ cls.NetworkLoggerRequestPrototype = function()
936937
if (header.name.toLowerCase() == "content-type")
937938
{
938939
this.request_type = header.value;
940+
this.boundary = header.value.split("; boundary=")[1] || "";
939941
break;
940942
}
941943
}
942944
this.firstline = event.raw.split("\n")[0]; // todo: event.raw.split("\r\n")[0];
943945
// The body can be contained in event.raw.
944946
// At the time of the this event, it's possible that more than the header
945947
// has been written to the socket already.
948+
this.raw = event.raw; // todo: debugging only. remove me.
946949
this.request_headers_raw = event.raw.split("\r\n\r\n")[0];
947950
};
948951

src/network/network_style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@
547547
margin: 10px 0;
548548
}
549549

550-
pre.network-body
550+
table pre.network-body
551551
{
552552
/* work-around CORE-46966: Big pre element breaks layout in a table */
553553
float: left;

src/scripts/spec_links.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,6 +2012,7 @@ SpecLinks.specs = {
20122012
"Content-MD5": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.15",
20132013
"Content-Range": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16",
20142014
"Content-Type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17",
2015+
"Content-Disposition": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1",
20152016
"Date": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.18",
20162017
"Clockless Origin Server Operation": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.18.1",
20172018
"ETag": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.19",

0 commit comments

Comments
 (0)