@@ -74,6 +74,7 @@ const kEncrypted = Symbol('encrypted');
7474const kHandle = Symbol ( 'handle' ) ;
7575const kID = Symbol ( 'id' ) ;
7676const kInit = Symbol ( 'init' ) ;
77+ const kInfoHeaders = Symbol ( 'sent-info-headers' ) ;
7778const kMaybeDestroy = Symbol ( 'maybe-destroy' ) ;
7879const kLocalSettings = Symbol ( 'local-settings' ) ;
7980const kOptions = Symbol ( 'options' ) ;
@@ -82,6 +83,8 @@ const kProceed = Symbol('proceed');
8283const kProtocol = Symbol ( 'protocol' ) ;
8384const kProxySocket = Symbol ( 'proxy-socket' ) ;
8485const kRemoteSettings = Symbol ( 'remote-settings' ) ;
86+ const kSentHeaders = Symbol ( 'sent-headers' ) ;
87+ const kSentTrailers = Symbol ( 'sent-trailers' ) ;
8588const kServer = Symbol ( 'server' ) ;
8689const kSession = Symbol ( 'session' ) ;
8790const kState = Symbol ( 'state' ) ;
@@ -256,6 +259,7 @@ function onStreamTrailers() {
256259 stream . destroy ( headersList ) ;
257260 return [ ] ;
258261 }
262+ stream [ kSentTrailers ] = trailers ;
259263 return headersList ;
260264}
261265
@@ -1344,6 +1348,7 @@ class ClientHttp2Session extends Http2Session {
13441348 throw headersList ;
13451349
13461350 const stream = new ClientHttp2Stream ( this , undefined , undefined , { } ) ;
1351+ stream [ kSentHeaders ] = headers ;
13471352
13481353 // Close the writable side of the stream if options.endStream is set.
13491354 if ( options . endStream )
@@ -1507,6 +1512,18 @@ class Http2Stream extends Duplex {
15071512 return `Http2Stream ${ util . format ( obj ) } ` ;
15081513 }
15091514
1515+ get sentHeaders ( ) {
1516+ return this [ kSentHeaders ] ;
1517+ }
1518+
1519+ get sentTrailers ( ) {
1520+ return this [ kSentTrailers ] ;
1521+ }
1522+
1523+ get sentInfoHeaders ( ) {
1524+ return this [ kInfoHeaders ] ;
1525+ }
1526+
15101527 get pending ( ) {
15111528 return this [ kID ] === undefined ;
15121529 }
@@ -1846,6 +1863,7 @@ function processRespondWithFD(self, fd, headers, offset = 0, length = -1,
18461863 state . flags |= STREAM_FLAGS_HEADERS_SENT ;
18471864
18481865 const headersList = mapToHeaders ( headers , assertValidPseudoHeaderResponse ) ;
1866+ self [ kSentHeaders ] = headers ;
18491867 if ( ! Array . isArray ( headersList ) ) {
18501868 self . destroy ( headersList ) ;
18511869 return ;
@@ -2076,6 +2094,7 @@ class ServerHttp2Stream extends Http2Stream {
20762094
20772095 const id = ret . id ( ) ;
20782096 const stream = new ServerHttp2Stream ( session , ret , id , options , headers ) ;
2097+ stream [ kSentHeaders ] = headers ;
20792098
20802099 if ( options . endStream )
20812100 stream . end ( ) ;
@@ -2135,6 +2154,7 @@ class ServerHttp2Stream extends Http2Stream {
21352154 const headersList = mapToHeaders ( headers , assertValidPseudoHeaderResponse ) ;
21362155 if ( ! Array . isArray ( headersList ) )
21372156 throw headersList ;
2157+ this [ kSentHeaders ] = headers ;
21382158
21392159 state . flags |= STREAM_FLAGS_HEADERS_SENT ;
21402160
@@ -2320,6 +2340,10 @@ class ServerHttp2Stream extends Http2Stream {
23202340 const headersList = mapToHeaders ( headers , assertValidPseudoHeaderResponse ) ;
23212341 if ( ! Array . isArray ( headersList ) )
23222342 throw headersList ;
2343+ if ( ! this [ kInfoHeaders ] )
2344+ this [ kInfoHeaders ] = [ headers ] ;
2345+ else
2346+ this [ kInfoHeaders ] . push ( headers ) ;
23232347
23242348 const ret = this [ kHandle ] . info ( headersList ) ;
23252349 if ( ret < 0 )
0 commit comments