-
-
Save bszwej/62c327d773051816ed4949fd40c82c74 to your computer and use it in GitHub Desktop.
const http = require('http'); | |
const server = http.createServer(); | |
server.on('request', (request, response) => { | |
let body = []; | |
request.on('data', (chunk) => { | |
body.push(chunk); | |
}).on('end', () => { | |
body = Buffer.concat(body).toString(); | |
console.log(`==== ${request.method} ${request.url}`); | |
console.log('> Headers'); | |
console.log(request.headers); | |
console.log('> Body'); | |
console.log(body); | |
response.end(); | |
}); | |
}).listen(8083); |
Smashing!
Nice!
The oneliner version, just copy past in your terminal:
node -e "const h = require('http');const s = h.createServer();const l = console.log;s.on('request', (rq, rs) => {let b = [];rq.on('data', (c) => {b.push(c);}).on('end', () => {b = Buffer.concat(b).toString();l('==== '+rq.method+' '+rq.url);l('> Headers');l(rq.headers);l('> Body');l(b);rs.end();});}).listen(8000);"
The oneliner version, just copy past in your terminal:
node -e "const h = require('http');const s = h.createServer();const l = console.log;s.on('request', (rq, rs) => {let b = [];rq.on('data', (c) => {b.push(c);}).on('end', () => {b = Buffer.concat(b).toString();l('==== '+rq.method+' '+rq.url);l('> Headers');l(rq.headers);l('> Body');l(b);rs.end();});}).listen(8000);"
Many thanks for this bro
Thanks