Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save simonmorley/8e2ce0f60778086559f45c5f745c3075 to your computer and use it in GitHub Desktop.
Save simonmorley/8e2ce0f60778086559f45c5f745c3075 to your computer and use it in GitHub Desktop.
base64 decode and decompress nodejs
const http = require('http');
var zlib = require('zlib');
http.createServer((request, response) => {
const { headers, method, url } = request;
console.log(request.headers);
let body = [];
request.on('error', (err) => {
console.error(err);
}).on('data', (chunk) => {
body.push(chunk);
}).on('end', () => {
var concated = Buffer.concat(body).toString();
body = Buffer.from(concated, 'base64')
zlib.inflate(body, function(aa,bb) {
console.log(bb,bb.toString())
})
});
}).listen(3000); // Activates this server, listening on port 8080.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment