-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.js
More file actions
40 lines (31 loc) · 785 Bytes
/
client.js
File metadata and controls
40 lines (31 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
var http = require('http');
(function run(){
if(require.main === module) {
start();
}
})();
function start() {
var dataResp = '';
var req = http.request({
hostname: 'localhost',
port: 10345,
path: '/',
method: 'POST',
}, function(res) {
res.on('data', function (chunk) {
dataResp += chunk;
});
res.on("end", function() {
console.log(`client: status code: ${res.statusCode}. data: ${dataResp}`);
});
res.on('error', function(e) {
console.log(`client: problem with response: ${e}`);
});
});
req.on('error', function(e) {
console.log(`client: problem with request: ${e}`);
});
req.end(new Buffer(26 * 1024 * 1024));
}
exports.start = start;