HTTP 0.9

Request

GET /index.html

Response

<h1>Hello World</h1>

Server:

const net = require('net');
net
  .createServer((socket) => {
    socket.on('data', (data) => {
      if (data.toString() === 'GET /index.html\r\n') {
        socket.write('<h1>Hello World</h1>');
      }
      socket.end();
    });
  })
  .listen(8080);

Client:

const net = require('net');

const client = new net.Socket();

client.connect('8080', 'localhost', () => {
  client.write('GET index.html\r\n');
});

client.on('data', (data) => {
  console.info(`Response from server: ${data.toString()}`);
  client.end();
});