11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst http = require('http'); 51cb0ef41Sopenharmony_ciconst msg = 'Hello'; 61cb0ef41Sopenharmony_ciconst server = http.createServer(function(req, res) { 71cb0ef41Sopenharmony_ci res.writeHead(200, { 'Content-Type': 'text/plain' }); 81cb0ef41Sopenharmony_ci res.end(msg); 91cb0ef41Sopenharmony_ci}).listen(0, function() { 101cb0ef41Sopenharmony_ci http.get({ port: this.address().port }, function(res) { 111cb0ef41Sopenharmony_ci let data = ''; 121cb0ef41Sopenharmony_ci res.on('readable', common.mustCall(function() { 131cb0ef41Sopenharmony_ci console.log('readable event'); 141cb0ef41Sopenharmony_ci let chunk; 151cb0ef41Sopenharmony_ci while ((chunk = res.read()) !== null) { 161cb0ef41Sopenharmony_ci data += chunk; 171cb0ef41Sopenharmony_ci } 181cb0ef41Sopenharmony_ci })); 191cb0ef41Sopenharmony_ci res.on('end', common.mustCall(function() { 201cb0ef41Sopenharmony_ci console.log('end event'); 211cb0ef41Sopenharmony_ci assert.strictEqual(msg, data); 221cb0ef41Sopenharmony_ci server.close(); 231cb0ef41Sopenharmony_ci })); 241cb0ef41Sopenharmony_ci }); 251cb0ef41Sopenharmony_ci}); 26