Created
June 12, 2018 11:32
-
-
Save simonmorley/8e2ce0f60778086559f45c5f745c3075 to your computer and use it in GitHub Desktop.
base64 decode and decompress nodejs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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