Skip to content

Cannot call method 'wrap' of undefined #2

Closed
demian85 opened this Issue Nov 23, 2011 · 7 comments

2 participants

@demian85
23 Nov 15:03:43 - Downloading file: http://www.canalpatrimonio.com/imagftp/im158430botticelli_birth_venus_2.jpg 

/var/www/illuminatis/application/scripts/node_modules/http-get/lib/http-get.js:259
                            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...

@SaltwaterC
Owner

Can't reproduce with:

var http = require('http-get')

http.get({
    url: 'http://www.canalpatrimonio.com/imagftp/im158430botticelli_birth_venus_2.jpg'
}, './foo.jpg', function (err, res) {
    console.error(err)
    console.log(res)
})

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

@SaltwaterC
Owner

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?

@demian85

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

@SaltwaterC
Owner

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: http://search.npmjs.org/#/http-get which is the latest v0.3.9.

@demian85

This image is served using gzip and it breaks: http://cdn.tu.taconeras.net/files/2011/11/katy-perry-music.jpg

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?

@SaltwaterC
Owner

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

@SaltwaterC
Owner

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.