Skip to content

Cannot call method 'wrap' of undefined #2

demian85 opened this Issue Nov 23, 2011 · 7 comments

2 participants

23 Nov 15:03:43 - Downloading file: 

                            var gunzip = gunzipstream.wrap(res, {encoding: null});
TypeError: Cannot call method 'wrap' of undefined
    at ClientRequest.<anonymous> (/var/www/illuminatis/application/scripts/node_modules/http-get/lib/http-get.js:259:34)
    at ClientRequest.emit (events.js:67:17)
    at HTTPParser.onIncoming (http.js:1226:11)
    at HTTPParser.onHeadersComplete (http.js:102:31)
    at Socket.ondata (http.js:1125:24)
    at TCP.onread (net.js:334:27)

gzbz2 module is installed, but I see you do not require the module, but instead a file relative to http-get.js ¿?

EDIT: ok I don't understand where to put the gzbz2 module or how to disable gzip. I tried "nogzip" option but still breaks...


Can't reproduce with:

var http = require('http-get')

    url: ''
}, './foo.jpg', function (err, res) {

Both with and without the gzbz2 optional dependency that actually breaks there.


The gzbz2 optional dependency may be installed by issuing npm install gzbz2. But the code can work without it. The relative file that used to load gzbz2 used to be an older dependency when gzbz2 itself used to be broken. I sent the patches to the upstream build. Are you using the latest version?


I don't know what happens but know I cannot reproduce this error either... did you update npm package?
Maybe you can integrate the zlib module that comes with node 0.6


It is planned for v0.4. Having zlib in node is way easier that the pain node-compress forks adds to the stack.

The package was updated 47 days ago according to this: which is the latest v0.3.9.


This image is served using gzip and it breaks:

I replaced gzbz2 module with zlib included in node 0.6 and it works. Do you want me to send a pull request or still plan to keep compatibility with node 0.4?


Thanks. I'll look into it in order to find out what went wrong. I don't have plans to keep v0.4 compatibility at all cost. The code itself is pretty much node version agnostic, except the gzip support. It could work with plain HTTP connections for node 0.4.11+ and with gzip decoding support for node 0.6+.


Fixed the issue. Although the http-get client requests the image without Accept-Encoding: gzip, the server responds with Content-Encoding: gzip which used to enable the gzip decoding, although gzbz2 is not installed. This breaks the protocol itself. If this happens, now it calls the callback with proper error argument.

If you want it to work with these kind of broken servers, install gzbz2 with this one liner:

npm install http-get gzbz2

This makes sure that the gzip support is always there, unless excluded via options.nogzip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.