commit 1f88a0e204433d28a33e7df66681bd74f27f3b0a Author: David Fifield david@bamsoftware.com Date: Sun Feb 22 15:14:07 2015 -0800
Read data before bailing out in onDataAvailable.
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interf... says "Your implementation of this method must read exactly aCount bytes of data before returning."
It's already downloaded, so it doesn't cost much to read it out of the buffer. Without this, I got "http channel Listener OnDataAvailable contract violation" in the console. (I had to purposely induce an overlong download to get it to happen.) --- firefox/components/main.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/firefox/components/main.js b/firefox/components/main.js index b851d49..0ec6831 100644 --- a/firefox/components/main.js +++ b/firefox/components/main.js @@ -434,15 +434,15 @@ MeekHTTPHelper.HttpStreamListener.prototype = { // https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIStream... onDataAvailable: function(request, context, stream, sourceOffset, length) { // dump("onDataAvailable " + length + " bytes\n"); - if (this.length + length > 1000000) { - request.cancel(Components.results.NS_ERROR_ILLEGAL_VALUE); - return; - } this.length += length; let input = Components.classes["@mozilla.org/binaryinputstream;1"] .createInstance(Components.interfaces.nsIBinaryInputStream); input.setInputStream(stream); this.body.push(String.fromCharCode.apply(null, input.readByteArray(length))); + if (this.length > 1000000) { + request.cancel(Components.results.NS_ERROR_ILLEGAL_VALUE); + return; + } }, };
tor-commits@lists.torproject.org