Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for Node.js 12 #77

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
// OutgoingMessage.prototype._headers is deprecated. The following code maintains backward compatibility.
this._headers = this.response._headers = this.response._headers || {};
// OutgoingMessage.prototype._headerNames is deprecated. The following code maintains backward compatibility. No need to set for newer version as it is unsettable. Patch to node core.
this.response._headerNames = this.response._headerNames || {};
}

//
// Proxy to emit "header" event
Expand Down