Http usage in nodejs

  node.js, question

Server code

// server.js
 var qs = require('querystring');
 require('http')
 .createServer((req, res) => {
 let body = '';
 req.on('data', (chunk) => {
 Body plus = chunk;
 });
 req.on('end', () => {
 res.writeHead(200);
 res.end('Done');
 Log ('gotname \ 033 [90m' plus qs.parse(body).name plus' \033[39m\n');
 });
 })
 .listen(3000);

Client code

// client.js
 var http = require('http'),
 qs = require('querystring');
 
 var options = {
 host: '127.0.0.1',
 port: 3000,
 url: '/',
 method: 'post'
 };
 
 var send = (theName) => {
 http
 .request(options, (res) => {
 res.setEncoding('utf8');
 res.on('end', () => {
 console.log('\n  \033[90m  request complete!  \033[39m');
 process.stdout.write('\n  your name: ');
 });
 })
 .end(qs.stringify({name: theName}));
 };
 
 process.stdout.write('\n  your name: ');
 process.stdin.resume();
 process.stdin.setEncoding('utf8');
 process.stdin.on('data', (name) => {
 send(name.replace('\r\n', ''));
 });

The result I expect is this:
图片描述

But the result is this:
图片描述

Client, not executed tores.on('end', () => {...})The statement inside,
And when my server is disconnected, the client does not disconnect automatically.
May I ask why? orz

Amendment:

// client.js
 var http = require('http'),
 qs = require('querystring');
 
 var options = {
 host: '127.0.0.1',
 port: 3000,
 url: '/',
 method: 'post'
 };
 
 var send = (theName) => {
 http
 .request(options, (res) => {
 res.setEncoding('utf8');
 //it is necessary to write an on data here, otherwise the end event will not be triggered.
 res.on('data', (chunk) => {
 
 });
 res.on('end', () => {
 console.log('\n  \033[90m  request complete!  \033[39m');
 process.stdout.write('\n  your name: ');
 });
 })
 .end(qs.stringify({name: theName}));
 };
 
 process.stdout.write('\n  your name: ');
 process.stdin.resume();
 process.stdin.setEncoding('utf8');
 process.stdin.on('data', (name) => {
 send(name.replace('\r\n', ''));
 });

Document inside has such a sentence:

图片描述

Do you want to “spend”dataEvents, don’t want to useend, I also slightly forced, but this is a fact, you accept it