()
| 56 | |
| 57 | let remaining = size; |
| 58 | function send() { |
| 59 | while (remaining > 0) { |
| 60 | const chunk = crypto.randomBytes(Math.min(64 * 1024, remaining)); |
| 61 | remaining -= chunk.length; |
| 62 | if (!res.write(chunk)) { |
| 63 | res.once('drain', send); |
| 64 | return; |
| 65 | } |
| 66 | } |
| 67 | res.end(); |
| 68 | console.log(`[Server] Done`); |
| 69 | } |
| 70 | send(); |
| 71 | }); |
| 72 |