summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2018-01-08 12:18:22 -0800
committerJames M Snell <jasnell@gmail.com>2018-01-11 11:55:19 -0800
commitee2e7fcd5ff330f036f6502cded21eb013941f89 (patch)
treecf272a93229258416dc9f0854d9854ac4629f313 /lib
parent20fe04f113fb81423585077265d3026584989232 (diff)
downloadandroid-node-v8-ee2e7fcd5ff330f036f6502cded21eb013941f89.tar.gz
android-node-v8-ee2e7fcd5ff330f036f6502cded21eb013941f89.tar.bz2
android-node-v8-ee2e7fcd5ff330f036f6502cded21eb013941f89.zip
http2: remember sent headers
Add sentHeaders, sentTrailers, and sentInfoHeaders properties on `Http2Stream`. PR-URL: https://github.com/nodejs/node/pull/18045 Fixes: https://github.com/nodejs/node/issues/16619 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/http2/core.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js
index d0bf5b1411..88afd08a15 100644
--- a/lib/internal/http2/core.js
+++ b/lib/internal/http2/core.js
@@ -76,6 +76,7 @@ const kEncrypted = Symbol('encrypted');
const kHandle = Symbol('handle');
const kID = Symbol('id');
const kInit = Symbol('init');
+const kInfoHeaders = Symbol('sent-info-headers');
const kMaybeDestroy = Symbol('maybe-destroy');
const kLocalSettings = Symbol('local-settings');
const kOptions = Symbol('options');
@@ -84,6 +85,8 @@ const kProceed = Symbol('proceed');
const kProtocol = Symbol('protocol');
const kProxySocket = Symbol('proxy-socket');
const kRemoteSettings = Symbol('remote-settings');
+const kSentHeaders = Symbol('sent-headers');
+const kSentTrailers = Symbol('sent-trailers');
const kServer = Symbol('server');
const kSession = Symbol('session');
const kState = Symbol('state');
@@ -258,6 +261,7 @@ function onStreamTrailers() {
stream.destroy(headersList);
return [];
}
+ stream[kSentTrailers] = trailers;
return headersList;
}
@@ -1348,6 +1352,7 @@ class ClientHttp2Session extends Http2Session {
throw headersList;
const stream = new ClientHttp2Stream(this, undefined, undefined, {});
+ stream[kSentHeaders] = headers;
// Close the writable side of the stream if options.endStream is set.
if (options.endStream)
@@ -1514,6 +1519,18 @@ class Http2Stream extends Duplex {
return `Http2Stream ${util.format(obj)}`;
}
+ get sentHeaders() {
+ return this[kSentHeaders];
+ }
+
+ get sentTrailers() {
+ return this[kSentTrailers];
+ }
+
+ get sentInfoHeaders() {
+ return this[kInfoHeaders];
+ }
+
get pending() {
return this[kID] === undefined;
}
@@ -1855,6 +1872,7 @@ function processRespondWithFD(self, fd, headers, offset = 0, length = -1,
state.flags |= STREAM_FLAGS_HEADERS_SENT;
const headersList = mapToHeaders(headers, assertValidPseudoHeaderResponse);
+ self[kSentHeaders] = headers;
if (!Array.isArray(headersList)) {
self.destroy(headersList);
return;
@@ -2085,6 +2103,7 @@ class ServerHttp2Stream extends Http2Stream {
const id = ret.id();
const stream = new ServerHttp2Stream(session, ret, id, options, headers);
+ stream[kSentHeaders] = headers;
if (options.endStream)
stream.end();
@@ -2144,6 +2163,7 @@ class ServerHttp2Stream extends Http2Stream {
const headersList = mapToHeaders(headers, assertValidPseudoHeaderResponse);
if (!Array.isArray(headersList))
throw headersList;
+ this[kSentHeaders] = headers;
state.flags |= STREAM_FLAGS_HEADERS_SENT;
@@ -2329,6 +2349,10 @@ class ServerHttp2Stream extends Http2Stream {
const headersList = mapToHeaders(headers, assertValidPseudoHeaderResponse);
if (!Array.isArray(headersList))
throw headersList;
+ if (!this[kInfoHeaders])
+ this[kInfoHeaders] = [headers];
+ else
+ this[kInfoHeaders].push(headers);
const ret = this[kHandle].info(headersList);
if (ret < 0)