Skip to content

Instantly share code, notes, and snippets.

View oscar60310's full-sized avatar
🐬

Ivan Tsai oscar60310

🐬
View GitHub Profile
@oscar60310
oscar60310 / echo.js
Last active November 16, 2021 15:51 — forked from bszwej/echo.js
Pure Node.js echo server, that logs all incoming http requests (method, path, headers, body).
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();