Permalink
Browse files

v0.3.9

  • Loading branch information...
1 parent d037860 commit d90223f5b1fe7f9f97bcedbb85bf0268d252f2a0 @SaltwaterC committed Oct 7, 2011
Showing with 11 additions and 129 deletions.
  1. +3 −0 CHANGELOG.md
  2. +1 −1 README.md
  3. +0 −124 lib/gunzipstream.js
  4. +6 −3 lib/http-get.js
  5. +1 −1 package.json
View
@@ -1,3 +1,6 @@
+## v0.3.9
+ * Updates the gzbz2 dependency to v0.1.1. Removes the bundled patched version of gunzipstream.js since the upstream avoids the gunzip -5 errors.
+
## v0.3.8
* Fixes [#1](https://github.com/SaltwaterC/http-get/issues/1): Get with file does not callback.
View
@@ -26,4 +26,4 @@ If you need gzip decoding support:
## Optional modules
- * gzbz2 for gzip decompression. It was reported that gzbz2 might not build successfully for some users, therefore it's now an optional dependency. However, it's still recommended to install gzbz2. This will be handled automatically when npm will eventually support [optionalDependencies](https://github.com/isaacs/npm/issues/995).
+ * gzbz2 v0.1.1+ for gzip decompression. It was reported that gzbz2 might not build successfully for some users, therefore it's now an optional dependency. However, it's still recommended to install gzbz2. This will be handled automatically when npm will eventually support [optionalDependencies](https://github.com/isaacs/npm/issues/995).
View
@@ -1,124 +0,0 @@
-// Copyright 2009, Acknack Ltd. All rights reserved.
-// 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.
-
-/**
- * This kind of wrapper will be moved into http-get itself when the patch from
- * this file makes it into the upstream gzbz2.
- */
-var haveGzip = false;
-try {
- var gzbz2 = require('gzbz2');
- haveGzip = true;
-} catch (e) {}
-
-exports.haveGzip = haveGzip;
-
-var fs = require('fs'),
- sys = require('sys'),
- stream = require('stream');
-
-/**
- * wrap an readable stream (for binary data) with gunzip
- */
-var GunzipStream = function(readStream, enc) {
- stream.Stream.call(this);
- var self = this;
-
- self.stream = readStream;
- self.gz = new gzbz2.Gunzip();
- self.gz.init({encoding: enc});
-
- self.ondata = function(data) {
- try {
- var inflated = self.gz.inflate(data);
- } catch (err) {
- self.gz.end();
- self.emit('error', err);
- self._cleanup();
- return;
- }
- self.emit('data', inflated);
- };
- self.onclose = function() {
- self.gz.end();
- self.emit('close');
- self._cleanup();
- };
- self.onend = function() {
- self.gz.end();
- self.emit('end');
- self._cleanup();
- };
- self.onerror = function(err) {
- self.gz.end();
- self.emit('error', err);
- self._cleanup();
- };
- self.pause = function() {
- self.stream.pause();
- };
- self.resume = function() {
- self.stream.resume();
- };
- self._cleanup = function() {
- self.stream.removeListener('data', self.ondata);
- self.stream.removeListener('close', self.onclose);
- self.stream.removeListener('end', self.onend);
- self.stream.removeListener('error', self.onerror);
- };
-
- self.stream.addListener('data', self.ondata);
- self.stream.addListener('end', self.onend);
- self.stream.addListener('close', self.onclose);
- self.stream.addListener('error', self.onerror);
-};
-sys.inherits(GunzipStream, stream.Stream);
-exports.GunzipStream = GunzipStream;
-
-/**
- * this method accepts 4 main flavors:
- *
- * none gunzip from stdin
- * ---------------------------------------------------------------
- * @param stream ReadStream, if null/undefined, use stdin
- * ---------------------------------------------------------------
- * @param path string pathname, if null/undefined: use stdin
- * ---------------------------------------------------------------
- * @param path string pathname, if null/undefined && options.fd == null/undefined, use stdin
- * @param options as would be given to fs.createReadStream()
- *
- * @return a GunzipStream object, the underlying ReadStream is available as attribute named 'stream'
- */
-exports.wrap = function() {
- // [stream] | [path, [options,]]
- var stream = arguments[0], options = arguments[1];
- var enc = options.encoding;
- if( stream == null ) {
- if( options.fd == null ) {
- stream = process.openStdin();
- }
- } else if( typeof stream == 'string' ) {
- if( options ) {
- // we want to use buffers
- options.encoding = null;
- }
- stream = fs.createReadStream(stream, options);
- } // else stream is all set, options (if provided) are ignored
- return new GunzipStream(stream, enc);
-};
View
@@ -7,8 +7,11 @@ var p = require('path');
var dns = require('dns');
var http = require('http');
var https = require('https');
-/* 3rd party patched module */
-var gunzipstream = require('./gunzipstream.js');
+/* 3rd party optional module */
+var gunzipstream;
+try {
+ gunzipstream = require('gzbz2/gunzipstream.js');
+} catch (e) {}
/* reads the package.json information */
var pack = JSON.parse(fs.readFileSync(p.resolve(__dirname + '/../package.json')).toString('utf8'));
/**
@@ -84,7 +87,7 @@ var processInput = function (options, reqId) {
var opt = {
headers: normalizeHeaders(options.headers)
};
- if ( ! options.nogzip && gunzipstream.haveGzip) {
+ if ( ! options.nogzip && gunzipstream) {
opt.headers['accept-encoding'] = 'gzip';
} else if (opt.headers['accept-encoding']) {
delete(opt.headers['accept-encoding']);
View
@@ -1,6 +1,6 @@
{
"name": "http-get",
- "version": "0.3.8",
+ "version": "0.3.9",
"main": "./lib/http-get.js",
"description": "Simple to use node.js HTTP / HTTPS client for downloading remote files. Supports transparent gzip decoding.",
"engines": {

0 comments on commit d90223f

Please sign in to comment.