Skip to content

Commit

Permalink
support for Node.js 12 (#64)
Browse files Browse the repository at this point in the history
* support for Node.js 12

* Backward compatible
  • Loading branch information
Xmader authored Jan 18, 2024
1 parent b69c2c0 commit 76d7f3d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/response-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,15 @@ 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 || {};
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
Expand Down

0 comments on commit 76d7f3d

Please sign in to comment.