Ticket #32472: test_client.js
File test_client.js, 451 bytes (added by , 4 years ago) |
---|
Line | |
---|---|
1 | const http = require('http'); |
2 | const req = http.request({ |
3 | host: '127.0.0.1', |
4 | port: 8000, |
5 | method: 'GET', |
6 | headers: { |
7 | 'Connection': 'close', |
8 | }, |
9 | path: '/', |
10 | }); |
11 | req.end(); |
12 | req.once('response', (res) => { |
13 | let 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 | }); |