-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathstream-serve.js
48 lines (41 loc) · 1.04 KB
/
stream-serve.js
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
41
42
43
44
45
46
47
48
require('http').createServer((request, response) => {
response.writeHead(200, {
'Content-Type': 'text/html',
'Transfer-Encoding': 'chunked',
})
setInterval(() => {
response.write('chunked\r\n')
}, 1000)
}).listen(8009);
console.log('Server running at http://127.0.0.1:8009/');// var http = require('http');
// const gen = (count) => {
// let t = ''
// while (count--) {
// t += '1'
// }
// return t
// }
// const repeat = (count, s, f, done) => {
// timer = setInterval(() => {
// count--
// if (count <= 0) {
// done()
// } else {
// f()
// }
// }, s)
// }
// http.createServer((request, response) => {
// response.writeHead(200, {
// 'Content-Type': 'text/html',
// 'Transfer-Encoding': 'chunked'
// })
// repeat(100, 10,
// () => {
// response.write(gen(1024 * 1000));
// },
// () => {
// response.end(`done`);
// }
// )
// }).listen(8000);