Bug 1404917 - Prevent multiple response content copies in parent and in content processes.
MozReview-Commit-ID: FwTEmQ13IgJ
--- a/devtools/client/netmonitor/src/connector/firefox-data-provider.js
+++ b/devtools/client/netmonitor/src/connector/firefox-data-provider.js
@@ -1,15 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-disable block-scoped-var */
"use strict";
+const Services = require("Services");
const { EVENTS } = require("../constants");
const { CurlUtils } = require("devtools/client/shared/curl");
const { fetchHeaders, formDataURI } = require("../utils/request-utils");
/**
* This object is responsible for fetching additional HTTP
* data from the backend.
*/
@@ -322,17 +323,22 @@ class FirefoxDataProvider {
// in case this method is called multiple times in a raw.
if (this.pendingResponseContentRequests.has(id)) {
return this.pendingResponseContentRequests.get(id);
}
let promise = this.webConsoleClient.getResponseContent(id)
.then(async response => {
let { mimeType } = response.content;
let { encoding, text } = response.content;
- let textString = await this.getLongString(text);
+ let textString;
+ if (typeof(text) == "number") {
+ textString = Services.responses[text];
+ } else {
+ textString = await this.getLongString(text);
+ }
let data = {
content: {
encoding,
mimeType,
text: textString,
},
};
--- a/devtools/shared/webconsole/network-monitor.js
+++ b/devtools/shared/webconsole/network-monitor.js
@@ -612,16 +612,25 @@ NetworkResponseListener.prototype = {
}
if (response.mimeType && this.request.contentCharset) {
response.mimeType += "; charset=" + this.request.contentCharset;
}
this.receivedData = "";
+ if (!Services.responses) {
+ Services.responses = [];
+ }
+
+ Services.responses.push(response.text);
+ dump("push("+(Services.responses.length-1)+" - "+response.text.substr(0, 10)+"\n");
+ response.text = Services.responses.length - 1;
+
+
this.httpActivity.owner.addResponseContent(
response,
this.httpActivity.discardResponseBody
);
this._wrappedNotificationCallbacks = null;
this.httpActivity = null;
this.sink = null;