From 4e40ea8630499111ed46473472751c6e6d60c722 Mon Sep 17 00:00:00 2001 From: Xmader Date: Tue, 4 Jun 2019 01:34:49 -0400 Subject: [PATCH 1/2] support for Node.js 12 --- lib/response-stream.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/response-stream.js b/lib/response-stream.js index e11b2d3..44575a8 100644 --- a/lib/response-stream.js +++ b/lib/response-stream.js @@ -47,10 +47,7 @@ var ResponseStream = module.exports = function (options) { }); if (this.response) { - this._headers = this.response._headers = this.response._headers || {}; - - // Patch to node core - this.response._headerNames = this.response._headerNames || {}; + this._headers = this.response.getHeaders() || {}; // // Proxy to emit "header" event From b3299a87020f85ca7122cf478f54ad711da2be25 Mon Sep 17 00:00:00 2001 From: Xmader Date: Tue, 4 Jun 2019 16:26:05 -0400 Subject: [PATCH 2/2] Backward compatible --- lib/response-stream.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/response-stream.js b/lib/response-stream.js index 44575a8..1efa5ce 100644 --- a/lib/response-stream.js +++ b/lib/response-stream.js @@ -47,7 +47,15 @@ var ResponseStream = module.exports = function (options) { }); if (this.response) { - this._headers = this.response.getHeaders() || {}; + + try { + this._headers = this.response.getHeaders() || {}; + } catch (err) { + this._headers = this.response._headers = this.response._headers || {}; + + // Patch to node core + this.response._headerNames = this.response._headerNames || {}; + } // // Proxy to emit "header" event