Skip to content
Merged
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) {
this._headers = this.response._headers = this.response._headers || {};

// Patch to node core
this.response._headerNames = this.response._headerNames || {};
Copy link

@lamweili lamweili Feb 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this not be in the catch, but in another try-catch?

// Patch to node core
try {
  this.response._headerNames = this.response.getHeaderNames() || {};
} catch (err) {
  this.response._headerNames = this.response._headerNames || {};  
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been commented in PR #77 that there is no need for this suggestion.
@darrendatbui has did some testing and the original committed code works.

I rest my case.

}

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