|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +constcommon=require('../common'); |
| 4 | +if(!common.hasCrypto) |
| 5 | +common.skip('missing crypto'); |
| 6 | + |
| 7 | +constassert=require('assert'); |
| 8 | +const{ createServer, constants, connect }=require('http2'); |
| 9 | + |
| 10 | +constserver=createServer(); |
| 11 | + |
| 12 | +server.on('stream',(stream,headers)=>{ |
| 13 | +stream.respond(undefined,{waitForTrailers: true}); |
| 14 | + |
| 15 | +stream.on('data',common.mustNotCall()); |
| 16 | + |
| 17 | +stream.on('wantTrailers',common.mustCall(()=>{ |
| 18 | +// Trigger a frame error by sending a trailer that is too large |
| 19 | +stream.sendTrailers({'test-trailer': 'X'.repeat(64*1024)}); |
| 20 | +})); |
| 21 | + |
| 22 | +stream.on('frameError',common.mustCall((frameType,errorCode)=>{ |
| 23 | +assert.strictEqual(errorCode,constants.NGHTTP2_FRAME_SIZE_ERROR); |
| 24 | +})); |
| 25 | + |
| 26 | +stream.on('error',common.expectsError({ |
| 27 | +code: 'ERR_HTTP2_STREAM_ERROR', |
| 28 | +})); |
| 29 | + |
| 30 | +stream.on('close',common.mustCall()); |
| 31 | + |
| 32 | +stream.end(); |
| 33 | +}); |
| 34 | + |
| 35 | +server.listen(0,()=>{ |
| 36 | +constclientSession=connect(`http://localhost:${server.address().port}`); |
| 37 | + |
| 38 | +clientSession.on('frameError',common.mustNotCall()); |
| 39 | +clientSession.on('close',common.mustCall(()=>{ |
| 40 | +server.close(); |
| 41 | +})); |
| 42 | + |
| 43 | +constclientStream=clientSession.request(); |
| 44 | + |
| 45 | +clientStream.on('close',common.mustCall()); |
| 46 | +// These events mustn't be called once the frame size error is from the server |
| 47 | +clientStream.on('frameError',common.mustNotCall()); |
| 48 | +clientStream.on('error',common.mustNotCall()); |
| 49 | + |
| 50 | +clientStream.end(); |
| 51 | +}); |
0 commit comments