Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: changed function to arrow function
Convert callback functions that are anonymous
to arrow functions for better readability.
Also adjusted the `this` object in places
where that was required.
  • Loading branch information
HarshithaKP committed Jul 17, 2019
commit a321ab7c33c80c9df6d9ffe275097e133831c025
14 changes: 7 additions & 7 deletions test/parallel/test-http-wget.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,38 +40,38 @@ const http = require('http');
// content-length is not provided, that the connection is in fact
// closed.

const server = http.createServer(function(req, res) {
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write('hello ');
res.write('world\n');
res.end();
});
server.listen(0);

server.on('listening', common.mustCall(function() {
const c = net.createConnection(this.address().port);
server.on('listening', common.mustCall(() => {
const c = net.createConnection(server.address().port);
let server_response = '';

c.setEncoding('utf8');

c.on('connect', function() {
c.on('connect', () => {
c.write('GET / HTTP/1.0\r\n' +
'Connection: Keep-Alive\r\n\r\n');
});

c.on('data', function(chunk) {
c.on('data', (chunk) => {
console.log(chunk);
server_response += chunk;
});

c.on('end', common.mustCall(function() {
c.on('end', common.mustCall(() => {
const m = server_response.split('\r\n\r\n');
assert.strictEqual(m[1], 'hello world\n');
console.log('got end');
c.end();
}));

c.on('close', common.mustCall(function() {
c.on('close', common.mustCall(() => {
console.log('got close');
server.close();
}));
Expand Down