mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-30 21:55:31 +00:00
Bug 989364 - Netmonitor should use CurlUtils to retrieve the request headers from upload stream, r=rcampbell
This commit is contained in:
parent
9ef5bdba36
commit
78b7a846a4
@ -120,6 +120,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "Chart",
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Curl",
|
||||
"resource:///modules/devtools/Curl.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "CurlUtils",
|
||||
"resource:///modules/devtools/Curl.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
||||
"resource://gre/modules/Task.jsm");
|
||||
|
||||
|
@ -1074,20 +1074,20 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
|
||||
// a loop, so remember the actual request item we want to modify.
|
||||
let currentItem = requestItem;
|
||||
let currentStore = { headers: [], headersSize: 0 };
|
||||
gNetwork.getString(value.postData.text).then(aPostData => {
|
||||
for (let section of aPostData.split(/\r\n|\r|\n/)) {
|
||||
// Try to retrieve header tuples from this section of the
|
||||
// POST data. The `parseHeadersText` function will return an
|
||||
// empty array if no headers are found. We're using Array.p.push
|
||||
// to avoid creating a new array when concatenating.
|
||||
let headerTuples = parseHeadersText(section);
|
||||
currentStore.headersSize += headerTuples.length ? section.length : 0;
|
||||
Array.prototype.push.apply(currentStore.headers, headerTuples);
|
||||
}
|
||||
|
||||
Task.spawn(function*() {
|
||||
let postData = yield gNetwork.getString(value.postData.text);
|
||||
let payloadHeaders = CurlUtils.getHeadersFromMultipartText(postData);
|
||||
|
||||
currentStore.headers = payloadHeaders;
|
||||
currentStore.headersSize = payloadHeaders.reduce(
|
||||
(acc, { name, value }) => acc + name.length + value.length + 2, 0);
|
||||
|
||||
// The `getString` promise is async, so we need to refresh the
|
||||
// information displayed in the network details pane again here.
|
||||
refreshNetworkDetailsPaneIfNecessary(currentItem);
|
||||
});
|
||||
|
||||
requestItem.attachment.requestPostData = value;
|
||||
requestItem.attachment.requestHeadersFromUploadStream = currentStore;
|
||||
break;
|
||||
|
@ -26,9 +26,10 @@
|
||||
|
||||
function performRequests() {
|
||||
var rawData = [
|
||||
"content-type: application/x-www-form-urlencoded",
|
||||
"custom-header: hello world!",
|
||||
"",
|
||||
"content-type: application/x-www-form-urlencoded\r",
|
||||
"custom-header: hello world!\r",
|
||||
"\r",
|
||||
"\r",
|
||||
"foo=bar&baz=123"
|
||||
];
|
||||
post("sjs_simple-test-server.sjs", rawData.join("\n"), function() {
|
||||
|
Loading…
Reference in New Issue
Block a user