Skip to content

Instantly share code, notes, and snippets.

@codenirvana
Created February 25, 2019 02:38
Show Gist options
  • Save codenirvana/afb41744865e13d77da7be7ed2f2539c to your computer and use it in GitHub Desktop.
Save codenirvana/afb41744865e13d77da7be7ed2f2539c to your computer and use it in GitHub Desktop.
Simple RAW HTTP Echo Server in Node.js
const net = require('net');
net.createServer(function (socket) {
socket.on('data', function (chunk) {
socket.write('HTTP/1.1 200 Ok\r\n');
socket.write('\r\n');
socket.write(chunk.toString());
socket.end();
});
}).listen(3000);
// start server: node rawEcho.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment