[Pkg-javascript-commits] [node-stream-http] 118/208: Replace buffer.buffer with more compatible version

Bastien Roucariès rouca at moszumanska.debian.org
Sun Aug 13 13:39:34 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 6433ea8cad234612bc45e13d5fdb08c3d1752937
Author: John Hiesey <john at hiesey.com>
Date:   Wed Jan 13 01:33:11 2016 +0100

    Replace buffer.buffer with more compatible version
    
    Unforunately some browsers use a version of Buffer
    that isn't based on a Uint8Array. Add logic to convert
    when necessary but not make copies when unnecessary.
---
 lib/request.js | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/request.js b/lib/request.js
index c784566..f01c0b2 100644
--- a/lib/request.js
+++ b/lib/request.js
@@ -96,7 +96,15 @@ ClientRequest.prototype._onFinish = function () {
 	if (opts.method === 'POST' || opts.method === 'PUT' || opts.method === 'PATCH') {
 		if (capability.blobConstructor) {
 			body = new global.Blob(self._body.map(function (buffer) {
-				return buffer.buffer
+				if (buffer instanceof Uint8Array) {
+					return buffer
+				} else {
+					var buf = new Uint8Array(buffer.length)
+					for (var i = 0, len = buf.length; i < len; i++) {
+						buf[i] = buffer[i]
+					}
+					return buf
+				}
 			}), {
 				type: (headersObj['content-type'] || {}).value || ''
 			})

-- 
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