diff --git a/toolkit/components/console/hudservice/HUDService.jsm b/toolkit/components/console/hudservice/HUDService.jsm index 8e043ac5dd1..08a8dc87a83 100644 --- a/toolkit/components/console/hudservice/HUDService.jsm +++ b/toolkit/components/console/hudservice/HUDService.jsm @@ -116,6 +116,9 @@ const SEARCH_DELAY = 200; // "devtools.hud.loglimit" preference. const DEFAULT_LOG_LIMIT = 200; +// The maximum number of bytes a Network ResponseListener can hold. +const RESPONSE_BODY_LIMIT = 1048576; // 1 MB + const ERRORS = { LOG_MESSAGE_MISSING_ARGS: "Missing arguments: aMessage, aConsoleNode and aMessageNode are required.", CANNOT_GET_HUD: "Cannot getHeads Up Display with provided ID", @@ -218,7 +221,12 @@ ResponseListener.prototype = binaryOutputStream = new BinaryOutputStream(storageStream.getOutputStream(0)); let data = NetUtil.readInputStreamToString(aInputStream, aCount); + + if (HUDService.saveRequestAndResponseBodies && + this.receivedData.length < RESPONSE_BODY_LIMIT) { this.receivedData += data; + } + binaryOutputStream.writeBytes(data, aCount); let newInputStream = storageStream.newInputStream(0); @@ -289,7 +297,9 @@ ResponseListener.prototype = } }); this.httpActivity.response.isDone = true; + this.httpActivity.response.listener = null; this.httpActivity = null; + this.receivedData = ""; }, QueryInterface: XPCOMUtils.generateQI([ diff --git a/toolkit/components/console/hudservice/tests/browser/browser_webconsole_netlogging.js b/toolkit/components/console/hudservice/tests/browser/browser_webconsole_netlogging.js index 98486735f73..78c77a537cb 100644 --- a/toolkit/components/console/hudservice/tests/browser/browser_webconsole_netlogging.js +++ b/toolkit/components/console/hudservice/tests/browser/browser_webconsole_netlogging.js @@ -70,6 +70,7 @@ function testNetworkLogging() is(httpActivity.method, "GET", "Method is correct"); ok(!("body" in httpActivity.request), "No request body was stored"); ok(!("body" in httpActivity.response), "No response body was stored"); + ok(!httpActivity.response.listener, "No response listener is stored"); // Turn on logging of request bodies and check again. // HUDService.saveRequestAndResponseBodies = true;