|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +// Test https highWaterMark |
| 4 | + |
| 5 | +constcommon=require('../common'); |
| 6 | +if(!common.hasCrypto) |
| 7 | +common.skip('missing crypto'); |
| 8 | + |
| 9 | +constassert=require('assert'); |
| 10 | +consthttps=require('https'); |
| 11 | +constfixtures=require('../common/fixtures'); |
| 12 | + |
| 13 | +letcounter=0; |
| 14 | + |
| 15 | +functionloadCallback(highWaterMark){ |
| 16 | +returncommon.mustCall(function(res){ |
| 17 | +assert.strictEqual(highWaterMark,res.readableHighWaterMark); |
| 18 | +counter--; |
| 19 | +console.log('back from https request. ', |
| 20 | +`highWaterMark = ${res.readableHighWaterMark}`); |
| 21 | +if(counter===0){ |
| 22 | +httpsServer.close(); |
| 23 | +console.log('ok'); |
| 24 | +} |
| 25 | +res.resume(); |
| 26 | +}); |
| 27 | +} |
| 28 | + |
| 29 | +// create server |
| 30 | +consthttpsServer=https.createServer({ |
| 31 | +key: fixtures.readKey('agent1-key.pem'), |
| 32 | +cert: fixtures.readKey('agent1-cert.pem') |
| 33 | +},common.mustCall(function(req,res){ |
| 34 | +res.writeHead(200,{}); |
| 35 | +res.end('ok'); |
| 36 | +},3)).listen(0,common.mustCall(function(err){ |
| 37 | +console.log(`test https server listening on port ${this.address().port}`); |
| 38 | +assert.ifError(err); |
| 39 | + |
| 40 | +https.request({ |
| 41 | +method: 'GET', |
| 42 | +path: `/${counter++}`, |
| 43 | +host: 'localhost', |
| 44 | +port: this.address().port, |
| 45 | +rejectUnauthorized: false, |
| 46 | +highWaterMark: 128000, |
| 47 | +},loadCallback(128000)).on('error',common.mustNotCall()).end(); |
| 48 | + |
| 49 | +https.request({ |
| 50 | +method: 'GET', |
| 51 | +path: `/${counter++}`, |
| 52 | +host: 'localhost', |
| 53 | +port: this.address().port, |
| 54 | +rejectUnauthorized: false, |
| 55 | +highWaterMark: 0, |
| 56 | +},loadCallback(0)).on('error',common.mustNotCall()).end(); |
| 57 | + |
| 58 | +https.request({ |
| 59 | +method: 'GET', |
| 60 | +path: `/${counter++}`, |
| 61 | +host: 'localhost', |
| 62 | +port: this.address().port, |
| 63 | +rejectUnauthorized: false, |
| 64 | +highWaterMark: undefined, |
| 65 | +},loadCallback(16*1024)).on('error',common.mustNotCall()).end(); |
| 66 | +})); |
0 commit comments