| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 94c4323 commit 9916ee8
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,12 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common'); | |
| 3 | - const assert = require('assert'); | ||
| 4 | 3 | ||
| 5 | 4 | if (!common.hasCrypto) { | |
| 6 | 5 | common.skip('missing crypto'); | |
| 7 | 6 | return; | |
| 8 | 7 | } | |
| 8 | + | ||
| 9 | + const assert = require('assert'); | ||
| 9 | 10 | const https = require('https'); | |
| 10 | 11 | ||
| 11 | 12 | const fs = require('fs'); | |
@@ -14,7 +15,7 @@ const key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'); | |||
| 14 | 15 | const cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'); | |
| 15 | 16 | ||
| 16 | 17 | // number of bytes discovered empirically to trigger the bug | |
| 17 | - const data = Buffer.allocUnsafe(1024 * 32 + 1); | ||
| 18 | + const data = Buffer.alloc(1024 * 32 + 1); | ||
| 18 | 19 | ||
| 19 | 20 | httpsTest(); | |
| 20 | 21 | ||
@@ -36,19 +37,18 @@ function httpsTest() { | |||
| 36 | 37 | } | |
| 37 | 38 | ||
| 38 | 39 | ||
| 39 | - function test(res) { | ||
| 40 | - res.on('end', function() { | ||
| 40 | + const test = common.mustCall(function(res) { | ||
| 41 | + res.on('end', common.mustCall(function() { | ||
| 41 | 42 | assert.strictEqual(res._readableState.length, 0); | |
| 42 | 43 | assert.strictEqual(bytes, data.length); | |
| 43 | - console.log('ok'); | ||
| 44 | - }); | ||
| 44 | + })); | ||
| 45 | 45 | ||
| 46 | 46 | // Pause and then resume on each chunk, to ensure that there will be | |
| 47 | 47 | // a lone byte hanging out at the very end. | |
| 48 | 48 | let bytes = 0; | |
| 49 | 49 | res.on('data', function(chunk) { | |
| 50 | 50 | bytes += chunk.length; | |
| 51 | 51 | this.pause(); | |
| 52 | - setTimeout(this.resume.bind(this)); | ||
| 52 | + setTimeout(this.resume.bind(this), 1); | ||
| 53 | 53 | }); | |
| 54 | - } | ||
| 54 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments