From cc0794a8e0461de4e09605e4b2bdcf369ff4becb Mon Sep 17 00:00:00 2001 From: Luis Reis Date: Tue, 9 Sep 2014 17:30:15 +0100 Subject: [PATCH 1/7] zlib: Add gzip/gunzip modes to reset. --- src/node_zlib.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/node_zlib.cc b/src/node_zlib.cc index 4f0c938998a..da33668a1ff 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -557,10 +557,12 @@ class ZCtx : public AsyncWrap { switch (ctx->mode_) { case DEFLATE: case DEFLATERAW: + case GZIP: ctx->err_ = deflateReset(&ctx->strm_); break; case INFLATE: case INFLATERAW: + case GUNZIP: ctx->err_ = inflateReset(&ctx->strm_); break; default: From 31f2b2c7bb75e87c871a359957703fad24dcaaa0 Mon Sep 17 00:00:00 2001 From: Luis Reis Date: Wed, 10 Sep 2014 12:40:54 +0100 Subject: [PATCH 2/7] zlib: Have CheckError return an enum instead of a boolean. --- src/node_zlib.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/node_zlib.cc b/src/node_zlib.cc index da33668a1ff..f01e95d34a7 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -63,6 +63,10 @@ enum node_zlib_mode { UNZIP }; +enum node_zlib_error { + NO_ERROR, + FAILED +}; void InitZlib(v8::Handle target); @@ -207,7 +211,7 @@ class ZCtx : public AsyncWrap { if (!async) { // sync version Process(work_req); - if (CheckError(ctx)) + if (CheckError(ctx) == NO_ERROR) AfterSync(ctx, args); return; } @@ -292,7 +296,7 @@ class ZCtx : public AsyncWrap { } - static bool CheckError(ZCtx* ctx) { + static node_zlib_error CheckError(ZCtx* ctx) { // Acceptable error states depend on the type of zlib stream. switch (ctx->err_) { case Z_OK: @@ -305,14 +309,14 @@ class ZCtx : public AsyncWrap { ZCtx::Error(ctx, "Missing dictionary"); else ZCtx::Error(ctx, "Bad dictionary"); - return false; + return FAILED; default: // something else. ZCtx::Error(ctx, "Zlib error"); - return false; + return FAILED; } - return true; + return NO_ERROR; } @@ -326,7 +330,7 @@ class ZCtx : public AsyncWrap { HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); - if (!CheckError(ctx)) + if (CheckError(ctx) == FAILED) return; Local avail_out = Integer::New(env->isolate(), From 4782440f9af4761a77724491dd85c0660a60bf5b Mon Sep 17 00:00:00 2001 From: Luis Reis Date: Wed, 10 Sep 2014 12:52:04 +0100 Subject: [PATCH 3/7] zlib: Add support for concatenated gzip streams. --- lib/zlib.js | 9 +- test/simple/test-zlib-from-multiple-gzip.js | 73 +++++++++++++++ .../test-zlib-from-multiple-huge-gzip.js | 92 +++++++++++++++++++ 3 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 test/simple/test-zlib-from-multiple-gzip.js create mode 100644 test/simple/test-zlib-from-multiple-huge-gzip.js diff --git a/lib/zlib.js b/lib/zlib.js index ad9ceaa7eb0..96eb08bdf4c 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -576,7 +576,7 @@ Zlib.prototype._processChunk = function(chunk, flushFlag, cb) { self._buffer = new Buffer(self._chunkSize); } - if (availOutAfter === 0) { + if (availOutAfter === 0 || availInAfter > 0) { // Not actually done. Need to reprocess. // Also, update the availInBefore to the availInAfter value, // so that if we have to hit it a third (fourth, etc.) time, @@ -584,6 +584,13 @@ Zlib.prototype._processChunk = function(chunk, flushFlag, cb) { inOff += (availInBefore - availInAfter); availInBefore = availInAfter; + if (availOutAfter !== 0) { + // There is still some data available for reading. + // This is usually a concatenated stream, so, reset and restart. + self.reset(); + self._offset = 0; + } + if (!async) return true; diff --git a/test/simple/test-zlib-from-multiple-gzip.js b/test/simple/test-zlib-from-multiple-gzip.js new file mode 100644 index 00000000000..0b006836b11 --- /dev/null +++ b/test/simple/test-zlib-from-multiple-gzip.js @@ -0,0 +1,73 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// test unzipping a file that was created by contactenating multiple gzip +// streams. + +var assert = require('assert'); +var zlib = require('zlib'); + +var util = require('util'); + +var gzipBuffer = new Buffer(128); +var gzipOffset = 0; + +var stream1 = '123\n'; +var stream2 = '456\n'; +var stream3 = '789\n'; + +function gzipAppend(data) { + data.copy(gzipBuffer, gzipOffset); + gzipOffset += data.length; +} + +function writeGzipStream(text, cb) { + var gzip = zlib.createGzip(); + gzip.on('data', gzipAppend); + gzip.write(text, function () { + gzip.flush(function () { + gzip.end(function () { + cb(); + }); + }); + }); +} + +writeGzipStream(stream1, function() { + writeGzipStream(stream2, function () { + writeGzipStream(stream3, function () { + var gunzip = zlib.createGunzip(); + var gunzippedData = new Buffer(2 * 1024); + var gunzippedOffset = 0; + gunzip.on('data', function (data) { + data.copy(gunzippedData, gunzippedOffset); + gunzippedOffset += data.length; + }); + gunzip.on('end', function () { + assert.equal(gunzippedData.toString('utf8', 0, gunzippedOffset), stream1 + stream2 + stream3); + }); + + gunzip.write(gzipBuffer.slice(0, gzipOffset), 'binary', function () { + gunzip.end(); + }); + }); + }); +}); diff --git a/test/simple/test-zlib-from-multiple-huge-gzip.js b/test/simple/test-zlib-from-multiple-huge-gzip.js new file mode 100644 index 00000000000..7a04315970b --- /dev/null +++ b/test/simple/test-zlib-from-multiple-huge-gzip.js @@ -0,0 +1,92 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// test unzipping a file that was created by contactenating multiple gzip +// streams. + +var assert = require('assert'); +var zlib = require('zlib'); + +var util = require('util'); + +var HUGE = 64 * 1024; + +var originalBuffer = new Buffer(3 * HUGE); +var originalOffset = 0; + +var gzipBuffer = new Buffer(3 * HUGE); +var gzipOffset = 0; + +function getRandomLetter() { + return (Math.random() * (122 - 97)) + 97; +} + +function generateHugeStream() { + var buffer = new Buffer(HUGE); + for (var i = 0; i < HUGE; i++) + buffer.writeUInt8(getRandomLetter(), i); + + buffer.copy(originalBuffer, originalOffset); + originalOffset += HUGE; + + return buffer; +} + +function gzipAppend(data) { + data.copy(gzipBuffer, gzipOffset); + gzipOffset += data.length; +} + +function writeGzipStream(text, cb) { + var gzip = zlib.createGzip(); + gzip.on('data', gzipAppend); + gzip.write(text, function () { + gzip.flush(function () { + gzip.end(function () { + cb(); + }); + }); + }); +} + +writeGzipStream(generateHugeStream(), function() { + writeGzipStream(generateHugeStream(), function () { + writeGzipStream(generateHugeStream(), function () { + var gunzip = zlib.createGunzip(); + var gunzippedData = new Buffer(3 * HUGE); + var gunzippedOffset = 0; + gunzip.on('data', function (data) { + data.copy(gunzippedData, gunzippedOffset); + gunzippedOffset += data.length; + }); + gunzip.on('end', function () { + var gunzippedStr = gunzippedData.toString('utf8', 0, gunzippedOffset); + var originalStr = originalBuffer.toString('utf8', 0, 3 * HUGE); + + assert.equal(gunzippedStr, originalStr); + }); + + gunzip.write(gzipBuffer.slice(0, gzipOffset), 'binary', function () { + gunzip.end(); + }); + }); + }); +}); From 918d6388cd8570dc3824036e8050441959b48f83 Mon Sep 17 00:00:00 2001 From: Luis Reis Date: Wed, 10 Sep 2014 13:02:45 +0100 Subject: [PATCH 4/7] zlib: On error, decompress as much as possible from concatenated gzip streams. --- src/node_zlib.cc | 19 ++++- ...st-zlib-from-multiple-gzip-with-garbage.js | 81 +++++++++++++++++++ 2 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 test/simple/test-zlib-from-multiple-gzip-with-garbage.js diff --git a/src/node_zlib.cc b/src/node_zlib.cc index f01e95d34a7..95907dd03fd 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -65,7 +65,8 @@ enum node_zlib_mode { enum node_zlib_error { NO_ERROR, - FAILED + FAILED, + WRITE_PENDING }; void InitZlib(v8::Handle target); @@ -312,8 +313,12 @@ class ZCtx : public AsyncWrap { return FAILED; default: // something else. - ZCtx::Error(ctx, "Zlib error"); - return FAILED; + if (ctx->strm_.total_out == 0) { + ZCtx::Error(ctx, "Zlib error"); + return FAILED; + } else { + return WRITE_PENDING; + } } return NO_ERROR; @@ -330,7 +335,8 @@ class ZCtx : public AsyncWrap { HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); - if (CheckError(ctx) == FAILED) + node_zlib_error error = CheckError(ctx); + if (error == FAILED) return; Local avail_out = Integer::New(env->isolate(), @@ -344,6 +350,11 @@ class ZCtx : public AsyncWrap { Local args[2] = { avail_in, avail_out }; ctx->MakeCallback(env->callback_string(), ARRAY_SIZE(args), args); + if (error == WRITE_PENDING) { + ZCtx::Error(ctx, "Zlib error"); + return; + } + ctx->Unref(); if (ctx->pending_close_) ctx->Close(); diff --git a/test/simple/test-zlib-from-multiple-gzip-with-garbage.js b/test/simple/test-zlib-from-multiple-gzip-with-garbage.js new file mode 100644 index 00000000000..4dae292f2c0 --- /dev/null +++ b/test/simple/test-zlib-from-multiple-gzip-with-garbage.js @@ -0,0 +1,81 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// test unzipping a file that was created by contactenating multiple gzip +// streams. + +var assert = require('assert'); +var zlib = require('zlib'); + +var util = require('util'); + +var gzipBuffer = new Buffer(128); +var gzipOffset = 0; + +var stream1 = '123\n'; +var stream2 = '456\n'; +var stream3 = '789\n'; + +function gzipAppend(data) { + data.copy(gzipBuffer, gzipOffset); + gzipOffset += data.length; +} + +function writeGzipStream(text, cb) { + var gzip = zlib.createGzip(); + gzip.on('data', gzipAppend); + gzip.write(text, function () { + gzip.flush(function () { + gzip.end(function () { + cb(); + }); + }); + }); +} + +function writeGarbageStream(text, cb) { + gzipAppend(new Buffer(text)); + cb(); +} + +writeGzipStream(stream1, function() { + writeGzipStream(stream2, function () { + writeGarbageStream(stream3, function () { + var gunzip = zlib.createGunzip(); + var gunzippedData = new Buffer(2 * 1024); + var gunzippedOffset = 0; + gunzip.on('data', function (data) { + data.copy(gunzippedData, gunzippedOffset); + gunzippedOffset += data.length; + }); + gunzip.on('error', function () { + assert.equal(gunzippedData.toString('utf8', 0, gunzippedOffset), stream1 + stream2); + }); + gunzip.on('end', function () { + assert.fail('end event not expected'); + }); + + gunzip.write(gzipBuffer.slice(0, gzipOffset), 'binary', function () { + gunzip.end(); + }); + }); + }); +}); From 4634e30e1bfd8a884e99761ef7eafd1ef3124a48 Mon Sep 17 00:00:00 2001 From: Luis Reis Date: Sat, 11 Oct 2014 12:24:13 -0700 Subject: [PATCH 5/7] zlib: Add require('../common') to multiple gzip stream tests. --- test/simple/test-zlib-from-multiple-gzip-with-garbage.js | 1 + test/simple/test-zlib-from-multiple-gzip.js | 1 + test/simple/test-zlib-from-multiple-huge-gzip.js | 1 + 3 files changed, 3 insertions(+) diff --git a/test/simple/test-zlib-from-multiple-gzip-with-garbage.js b/test/simple/test-zlib-from-multiple-gzip-with-garbage.js index 4dae292f2c0..bdbd18bd99e 100644 --- a/test/simple/test-zlib-from-multiple-gzip-with-garbage.js +++ b/test/simple/test-zlib-from-multiple-gzip-with-garbage.js @@ -22,6 +22,7 @@ // test unzipping a file that was created by contactenating multiple gzip // streams. +var common = require('../common'); var assert = require('assert'); var zlib = require('zlib'); diff --git a/test/simple/test-zlib-from-multiple-gzip.js b/test/simple/test-zlib-from-multiple-gzip.js index 0b006836b11..00063541c9e 100644 --- a/test/simple/test-zlib-from-multiple-gzip.js +++ b/test/simple/test-zlib-from-multiple-gzip.js @@ -22,6 +22,7 @@ // test unzipping a file that was created by contactenating multiple gzip // streams. +var common = require('../common'); var assert = require('assert'); var zlib = require('zlib'); diff --git a/test/simple/test-zlib-from-multiple-huge-gzip.js b/test/simple/test-zlib-from-multiple-huge-gzip.js index 7a04315970b..0952961ccdf 100644 --- a/test/simple/test-zlib-from-multiple-huge-gzip.js +++ b/test/simple/test-zlib-from-multiple-huge-gzip.js @@ -22,6 +22,7 @@ // test unzipping a file that was created by contactenating multiple gzip // streams. +var common = require('../common'); var assert = require('assert'); var zlib = require('zlib'); From fb973d35f14825ae77acdc2c168ae72fbfb4fb7f Mon Sep 17 00:00:00 2001 From: Luis Reis Date: Sat, 11 Oct 2014 12:32:47 -0700 Subject: [PATCH 6/7] zlib: Fix typo in multiple gzip stream test comments. --- test/simple/test-zlib-from-multiple-gzip-with-garbage.js | 2 +- test/simple/test-zlib-from-multiple-gzip.js | 2 +- test/simple/test-zlib-from-multiple-huge-gzip.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/simple/test-zlib-from-multiple-gzip-with-garbage.js b/test/simple/test-zlib-from-multiple-gzip-with-garbage.js index bdbd18bd99e..2eb8e443851 100644 --- a/test/simple/test-zlib-from-multiple-gzip-with-garbage.js +++ b/test/simple/test-zlib-from-multiple-gzip-with-garbage.js @@ -19,7 +19,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -// test unzipping a file that was created by contactenating multiple gzip +// test unzipping a file that was created by concatenating multiple gzip // streams. var common = require('../common'); diff --git a/test/simple/test-zlib-from-multiple-gzip.js b/test/simple/test-zlib-from-multiple-gzip.js index 00063541c9e..7bbce1d1a18 100644 --- a/test/simple/test-zlib-from-multiple-gzip.js +++ b/test/simple/test-zlib-from-multiple-gzip.js @@ -19,7 +19,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -// test unzipping a file that was created by contactenating multiple gzip +// test unzipping a file that was created by concatenating multiple gzip // streams. var common = require('../common'); diff --git a/test/simple/test-zlib-from-multiple-huge-gzip.js b/test/simple/test-zlib-from-multiple-huge-gzip.js index 0952961ccdf..7c685a51f86 100644 --- a/test/simple/test-zlib-from-multiple-huge-gzip.js +++ b/test/simple/test-zlib-from-multiple-huge-gzip.js @@ -19,7 +19,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -// test unzipping a file that was created by contactenating multiple gzip +// test unzipping a file that was created by concatenating multiple gzip // streams. var common = require('../common'); From 2a9ec95af2d05158a910bc0dfa9902a856d8c2dd Mon Sep 17 00:00:00 2001 From: Luis Reis Date: Sat, 11 Oct 2014 12:37:10 -0700 Subject: [PATCH 7/7] zlib: Fix coding style issues on multiple gzip stream tests. --- ...st-zlib-from-multiple-gzip-with-garbage.js | 19 ++++++++++--------- test/simple/test-zlib-from-multiple-gzip.js | 14 +++++++------- .../test-zlib-from-multiple-huge-gzip.js | 14 +++++++------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/test/simple/test-zlib-from-multiple-gzip-with-garbage.js b/test/simple/test-zlib-from-multiple-gzip-with-garbage.js index 2eb8e443851..f6a0185e011 100644 --- a/test/simple/test-zlib-from-multiple-gzip-with-garbage.js +++ b/test/simple/test-zlib-from-multiple-gzip-with-garbage.js @@ -43,9 +43,9 @@ function gzipAppend(data) { function writeGzipStream(text, cb) { var gzip = zlib.createGzip(); gzip.on('data', gzipAppend); - gzip.write(text, function () { - gzip.flush(function () { - gzip.end(function () { + gzip.write(text, function() { + gzip.flush(function() { + gzip.end(function() { cb(); }); }); @@ -58,8 +58,8 @@ function writeGarbageStream(text, cb) { } writeGzipStream(stream1, function() { - writeGzipStream(stream2, function () { - writeGarbageStream(stream3, function () { + writeGzipStream(stream2, function() { + writeGarbageStream(stream3, function() { var gunzip = zlib.createGunzip(); var gunzippedData = new Buffer(2 * 1024); var gunzippedOffset = 0; @@ -67,14 +67,15 @@ writeGzipStream(stream1, function() { data.copy(gunzippedData, gunzippedOffset); gunzippedOffset += data.length; }); - gunzip.on('error', function () { - assert.equal(gunzippedData.toString('utf8', 0, gunzippedOffset), stream1 + stream2); + gunzip.on('error', function() { + assert.equal(gunzippedData.toString('utf8', 0, gunzippedOffset), + stream1 + stream2); }); - gunzip.on('end', function () { + gunzip.on('end', function() { assert.fail('end event not expected'); }); - gunzip.write(gzipBuffer.slice(0, gzipOffset), 'binary', function () { + gunzip.write(gzipBuffer.slice(0, gzipOffset), 'binary', function() { gunzip.end(); }); }); diff --git a/test/simple/test-zlib-from-multiple-gzip.js b/test/simple/test-zlib-from-multiple-gzip.js index 7bbce1d1a18..6f4127a4d30 100644 --- a/test/simple/test-zlib-from-multiple-gzip.js +++ b/test/simple/test-zlib-from-multiple-gzip.js @@ -43,9 +43,9 @@ function gzipAppend(data) { function writeGzipStream(text, cb) { var gzip = zlib.createGzip(); gzip.on('data', gzipAppend); - gzip.write(text, function () { - gzip.flush(function () { - gzip.end(function () { + gzip.write(text, function() { + gzip.flush(function() { + gzip.end(function() { cb(); }); }); @@ -53,8 +53,8 @@ function writeGzipStream(text, cb) { } writeGzipStream(stream1, function() { - writeGzipStream(stream2, function () { - writeGzipStream(stream3, function () { + writeGzipStream(stream2, function() { + writeGzipStream(stream3, function() { var gunzip = zlib.createGunzip(); var gunzippedData = new Buffer(2 * 1024); var gunzippedOffset = 0; @@ -62,11 +62,11 @@ writeGzipStream(stream1, function() { data.copy(gunzippedData, gunzippedOffset); gunzippedOffset += data.length; }); - gunzip.on('end', function () { + gunzip.on('end', function() { assert.equal(gunzippedData.toString('utf8', 0, gunzippedOffset), stream1 + stream2 + stream3); }); - gunzip.write(gzipBuffer.slice(0, gzipOffset), 'binary', function () { + gunzip.write(gzipBuffer.slice(0, gzipOffset), 'binary', function() { gunzip.end(); }); }); diff --git a/test/simple/test-zlib-from-multiple-huge-gzip.js b/test/simple/test-zlib-from-multiple-huge-gzip.js index 7c685a51f86..5533aafeb72 100644 --- a/test/simple/test-zlib-from-multiple-huge-gzip.js +++ b/test/simple/test-zlib-from-multiple-huge-gzip.js @@ -59,9 +59,9 @@ function gzipAppend(data) { function writeGzipStream(text, cb) { var gzip = zlib.createGzip(); gzip.on('data', gzipAppend); - gzip.write(text, function () { - gzip.flush(function () { - gzip.end(function () { + gzip.write(text, function() { + gzip.flush(function() { + gzip.end(function() { cb(); }); }); @@ -69,8 +69,8 @@ function writeGzipStream(text, cb) { } writeGzipStream(generateHugeStream(), function() { - writeGzipStream(generateHugeStream(), function () { - writeGzipStream(generateHugeStream(), function () { + writeGzipStream(generateHugeStream(), function() { + writeGzipStream(generateHugeStream(), function() { var gunzip = zlib.createGunzip(); var gunzippedData = new Buffer(3 * HUGE); var gunzippedOffset = 0; @@ -78,14 +78,14 @@ writeGzipStream(generateHugeStream(), function() { data.copy(gunzippedData, gunzippedOffset); gunzippedOffset += data.length; }); - gunzip.on('end', function () { + gunzip.on('end', function() { var gunzippedStr = gunzippedData.toString('utf8', 0, gunzippedOffset); var originalStr = originalBuffer.toString('utf8', 0, 3 * HUGE); assert.equal(gunzippedStr, originalStr); }); - gunzip.write(gzipBuffer.slice(0, gzipOffset), 'binary', function () { + gunzip.write(gzipBuffer.slice(0, gzipOffset), 'binary', function() { gunzip.end(); }); });