我在服务器上 GZip 一些 JSON 数据,通过 Web Sockets 的 Engine.IO 实现发送它
function sendResourceDataToObserver(socket, data) {
zlib.gzip(data, function (_, result) {
socket.send(result);
});
}
并使用我使用 Browserify ( http://browserify.org/ )导入的 ZLIB 模块对其进行解压缩
socket.on('message', function (data) {
zlib.gunzip(data, function(err, decoded) {
if (err) {
console.error(err);
}
console.log(decoded);
});
});
但是我得到了这个错误('decoded'显然是未定义的):
Error: invalid file signature:,�
at Error (<anonymous>)
at nb.i (http://localhost:5000/bundle.js:1994:184)
at Bb (http://localhost:5000/bundle.js:2000:424)
at http://localhost:5000/bundle.js:2000:338
at http://localhost:5000/bundle.js:1869:21
有任何想法吗?