Skip to content

Instantly share code, notes, and snippets.

@notionparallax
Created September 29, 2016 06:17
Show Gist options
  • Save notionparallax/e88d2ea314037c7ab4ed36a3374971ef to your computer and use it in GitHub Desktop.
Save notionparallax/e88d2ea314037c7ab4ed36a3374971ef to your computer and use it in GitHub Desktop.
var rawParser = bodyParser.raw({type: '*/*'});
app.post('/zipped', rawParser, function(req, res) {
console.log('here we go');
console.log('body', req.body);
console.log('req body len', req.body.length);
console.log('body.toString',req.body.toString() );
// console.log('body.toJSON', req.body.toJSON() );
var theData = req.body.toJSON();
console.log("d:", theData["data"].toString());
b = new Buffer(theData["data"]);
console.log("b:", b);
zlib.inflate(b, function(err, buf) {
console.log("in the inflate callback:", err, buf);
console.log("to string:", buf/*.toString("utf8")*/ );
});
res.status(200).send("I'm in ur zipped route");
});
here we go
body <Buffer 64 3d 78 25 39 43 25 38 42 25 41 45 56 25 43 41 25 32 46 25 43 39 48 2d 25 46 32 4e 25 41 44 54 25 42 32 52 50 32 52 25 44 32 51 50 25 43 41 25 30 36 ... >
req body len 94
body.toString d=x%9C%8B%AEV%CA%2F%C9H-%F2N%ADT%B2RP2R%D2QP%CA%06%B3%0Dku%14P%25M%10%92%C6%B5%B1%00%F8E%10%7F
d: 100,61,120,37,57,67,37,56,66,37,65,69,86,37,67,65,37,50,70,37,67,57,72,45,37,70,50,78,37,65,68,84,37,66,50,82,80,50,82,37,68,50,81,80,37,67,65,37,48,54,37,66,51,37,48,68,107,117,37,49,52,80,37,50,53,77,37,49,48,37,57,50,37,67,54,37,66,53,37,66,49,37,48,48,37,70,56,69,37,49,48,37,55,70
b: <Buffer 64 3d 78 25 39 43 25 38 42 25 41 45 56 25 43 41 25 32 46 25 43 39 48 2d 25 46 32 4e 25 41 44 54 25 42 32 52 50 32 52 25 44 32 51 50 25 43 41 25 30 36 ... >
in the inflate callback: { [Error: incorrect header check] errno: -3, code: 'Z_DATA_ERROR' } undefined
to string: undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment