[Pkg-javascript-commits] [node-stream-http] 04/208: Fix Firefox

Bastien Roucariès rouca at moszumanska.debian.org
Sun Aug 13 13:39:22 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-stream-http.

commit 17645e6bd6df7a3d4316b70d3000a24ba3122594
Author: John Hiesey <john at hiesey.com>
Date:   Wed Jul 1 17:16:23 2015 -0700

    Fix Firefox
---
 request.js  | 7 +++++++
 response.js | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/request.js b/request.js
index ef2b727..f769d4e 100644
--- a/request.js
+++ b/request.js
@@ -125,6 +125,13 @@ ClientRequest.prototype._onFinish = function () {
 					break
 			}
 		}
+		// Necessary for streaming in Firefox, since xhr.response is ONLY defined
+		// in onprogress, not in onreadystatechange with xhr.readyState = 3
+		if (self._mode === 'moz-chunked-arraybuffer') {
+			xhr.onprogress = function () {
+				self._response._onXHRReadyStateChange()
+			}
+		}
 
 		xhr.send(body)
 		// This is the best approximation to where 'socket' should be fired
diff --git a/response.js b/response.js
index 436b21d..e038896 100644
--- a/response.js
+++ b/response.js
@@ -103,9 +103,9 @@ IncomingMessage.prototype._onXHRReadyStateChange = function () {
 			}
 			break
 		case 'moz-chunked-arraybuffer': // take whole
-			if (xhr.readyState !== rStates.LOADING)
+			if (xhr.readyState !== rStates.LOADING || !xhr.response)
 				break
-			self.push(new Buffer(xhr.response))
+			self.push(new Buffer(new Uint8Array(xhr.response)))
 			break
 		case 'ms-stream':
 			if (xhr.readyState !== rStates.LOADING)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-stream-http.git



More information about the Pkg-javascript-commits mailing list