Ticket #32472: test_client.js

File test_client.js, 451 bytes (added by David Sanders, 3 years ago)

NodeJS Test Client

Line 
1const http = require('http');
2const req = http.request({
3 host: '127.0.0.1',
4 port: 8000,
5 method: 'GET',
6 headers: {
7 'Connection': 'close',
8 },
9 path: '/',
10 });
11req.end();
12req.once('response', (res) => {
13let allData = ""
14 res.on('data', chunk => {
15 allData += chunk.toString()
16 console.log("Chunk Length:", chunk.length)
17 })
18 res.on('end', () => {
19 console.log("Total Length:", allData.length)
20 })
21});
Back to Top