()
| 1091 | res.writeHead(200, {'Content-Type': 'text/html'}); |
| 1092 | let pos = 0; |
| 1093 | const writeChunk = function () { |
| 1094 | const chunk = file.substring( |
| 1095 | pos, |
| 1096 | Math.min(pos + stream, file.length) |
| 1097 | ); |
| 1098 | res.write(chunk); |
| 1099 | pos += stream; |
| 1100 | if (pos < file.length) { |
| 1101 | setTimeout(writeChunk, 500); |
| 1102 | } else { |
| 1103 | res.end(); |
| 1104 | } |
| 1105 | }; |
| 1106 | writeChunk(); |
| 1107 | } else { |
| 1108 | res.send(file); |