@@ -76,6 +76,7 @@ const kEncrypted = Symbol('encrypted');
7676const kHandle = Symbol ( 'handle' ) ;
7777const kID = Symbol ( 'id' ) ;
7878const kInit = Symbol ( 'init' ) ;
79+ const kInfoHeaders = Symbol ( 'sent-info-headers' ) ;
7980const kMaybeDestroy = Symbol ( 'maybe-destroy' ) ;
8081const kLocalSettings = Symbol ( 'local-settings' ) ;
8182const kOptions = Symbol ( 'options' ) ;
@@ -84,6 +85,8 @@ const kProceed = Symbol('proceed');
8485const kProtocol = Symbol ( 'protocol' ) ;
8586const kProxySocket = Symbol ( 'proxy-socket' ) ;
8687const kRemoteSettings = Symbol ( 'remote-settings' ) ;
88+ const kSentHeaders = Symbol ( 'sent-headers' ) ;
89+ const kSentTrailers = Symbol ( 'sent-trailers' ) ;
8790const kServer = Symbol ( 'server' ) ;
8891const kSession = Symbol ( 'session' ) ;
8992const kState = Symbol ( 'state' ) ;
@@ -258,6 +261,7 @@ function onStreamTrailers() {
258261 stream . destroy ( headersList ) ;
259262 return [ ] ;
260263 }
264+ stream [ kSentTrailers ] = trailers ;
261265 return headersList ;
262266}
263267
@@ -1348,6 +1352,7 @@ class ClientHttp2Session extends Http2Session {
13481352 throw headersList ;
13491353
13501354 const stream = new ClientHttp2Stream ( this , undefined , undefined , { } ) ;
1355+ stream [ kSentHeaders ] = headers ;
13511356
13521357 // Close the writable side of the stream if options.endStream is set.
13531358 if ( options . endStream )
@@ -1514,6 +1519,18 @@ class Http2Stream extends Duplex {
15141519 return `Http2Stream ${ util . format ( obj ) } ` ;
15151520 }
15161521
1522+ get sentHeaders ( ) {
1523+ return this [ kSentHeaders ] ;
1524+ }
1525+
1526+ get sentTrailers ( ) {
1527+ return this [ kSentTrailers ] ;
1528+ }
1529+
1530+ get sentInfoHeaders ( ) {
1531+ return this [ kInfoHeaders ] ;
1532+ }
1533+
15171534 get pending ( ) {
15181535 return this [ kID ] === undefined ;
15191536 }
@@ -1855,6 +1872,7 @@ function processRespondWithFD(self, fd, headers, offset = 0, length = -1,
18551872 state . flags |= STREAM_FLAGS_HEADERS_SENT ;
18561873
18571874 const headersList = mapToHeaders ( headers , assertValidPseudoHeaderResponse ) ;
1875+ self [ kSentHeaders ] = headers ;
18581876 if ( ! Array . isArray ( headersList ) ) {
18591877 self . destroy ( headersList ) ;
18601878 return ;
@@ -2085,6 +2103,7 @@ class ServerHttp2Stream extends Http2Stream {
20852103
20862104 const id = ret . id ( ) ;
20872105 const stream = new ServerHttp2Stream ( session , ret , id , options , headers ) ;
2106+ stream [ kSentHeaders ] = headers ;
20882107
20892108 if ( options . endStream )
20902109 stream . end ( ) ;
@@ -2144,6 +2163,7 @@ class ServerHttp2Stream extends Http2Stream {
21442163 const headersList = mapToHeaders ( headers , assertValidPseudoHeaderResponse ) ;
21452164 if ( ! Array . isArray ( headersList ) )
21462165 throw headersList ;
2166+ this [ kSentHeaders ] = headers ;
21472167
21482168 state . flags |= STREAM_FLAGS_HEADERS_SENT ;
21492169
@@ -2329,6 +2349,10 @@ class ServerHttp2Stream extends Http2Stream {
23292349 const headersList = mapToHeaders ( headers , assertValidPseudoHeaderResponse ) ;
23302350 if ( ! Array . isArray ( headersList ) )
23312351 throw headersList ;
2352+ if ( ! this [ kInfoHeaders ] )
2353+ this [ kInfoHeaders ] = [ headers ] ;
2354+ else
2355+ this [ kInfoHeaders ] . push ( headers ) ;
23322356
23332357 const ret = this [ kHandle ] . info ( headersList ) ;
23342358 if ( ret < 0 )
0 commit comments