| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 48959dd commit d90594a
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,10 @@ const common = require('../common'); | |||
| 3 | 3 | if (!common.hasCrypto) | |
| 4 | 4 | common.skip('missing crypto'); | |
| 5 | 5 | ||
| 6 | + // This tests that the http2 server sends data early when it accumulates | ||
| 7 | + // enough from ongoing requests to avoid DoS as mitigation for | ||
| 8 | + // CVE-2019-9517 and CVE-2019-9511. | ||
| 9 | + // Added by https://github.com/nodejs/node/commit/8a4a193 | ||
| 6 | 10 | const fixtures = require('../common/fixtures'); | |
| 7 | 11 | const assert = require('assert'); | |
| 8 | 12 | const http2 = require('http2'); | |
@@ -12,18 +16,20 @@ const content = fixtures.readSync('person-large.jpg'); | |||
| 12 | 16 | const server = http2.createServer({ | |
| 13 | 17 | maxSessionMemory: 1000 | |
| 14 | 18 | }); | |
| 19 | + let streamCount = 0; | ||
| 15 | 20 | server.on('stream', (stream, headers) => { | |
| 16 | 21 | stream.respond({ | |
| 17 | 22 | 'content-type': 'image/jpeg', | |
| 18 | 23 | ':status': 200 | |
| 19 | 24 | }); | |
| 20 | 25 | stream.end(content); | |
| 26 | + console.log('server sends content', ++streamCount); | ||
| 21 | 27 | }); | |
| 22 | - server.unref(); | ||
| 23 | 28 | ||
| 24 | 29 | server.listen(0, common.mustCall(() => { | |
| 25 | 30 | const client = http2.connect(`http://localhost:${server.address().port}/`); | |
| 26 | 31 | ||
| 32 | + let endCount = 0; | ||
| 27 | 33 | let finished = 0; | |
| 28 | 34 | for (let i = 0; i < 100; i++) { | |
| 29 | 35 | const req = client.request({ ':path': '/' }).end(); | |
@@ -32,8 +38,16 @@ server.listen(0, common.mustCall(() => { | |||
| 32 | 38 | chunks.push(chunk); | |
| 33 | 39 | }); | |
| 34 | 40 | req.on('end', common.mustCall(() => { | |
| 41 | + console.log('client receives content', ++endCount); | ||
| 35 | 42 | assert.deepStrictEqual(Buffer.concat(chunks), content); | |
| 36 | - if (++finished === 100) client.close(); | ||
| 43 | + | ||
| 44 | + if (++finished === 100) { | ||
| 45 | + client.close(); | ||
| 46 | + server.close(); | ||
| 47 | + } | ||
| 37 | 48 | })); | |
| 49 | + req.on('error', (e) => { | ||
| 50 | + console.log('client error', e); | ||
| 51 | + }); | ||
| 38 | 52 | } | |
| 39 | 53 | })); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments