Skip to content
Closed
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@ Response.prototype.get = function get(name) {
* @function getHeaders
* @returns {Object}
*/
Response.prototype.getHeaders = function getHeaders() {
return (this._headers || {});
};
if (typeof Response.prototype.getHeaders !== 'function') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please move the JS Doc down into the if block on top of the function? Additionally If you could then add a comment before the if block about why this is necessary, that'd be great. Once we get the comments fixed we should be ready to land this. Thanks so much!

Copy link
Author

@ianvonholt ianvonholt Jul 12, 2017

Choose a reason for hiding this comment

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

@retrohacker beat me to it. Thank you for the quick response. May we get a npm minor version bump for this?

Response.prototype.getHeaders = function getHeaders() {
return (this._headers || {});
};
}
Response.prototype.headers = Response.prototype.getHeaders;

/**
Expand Down
6 changes: 5 additions & 1 deletion test/response.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,11 @@ test('GH-951: sendRaw accepts only strings or buffers', function (t) {

SERVER.on('uncaughtException', function (req, res, route, err) {
t.ok(err);
t.equal(err.name, 'AssertionError');
// Node v8 uses static error codes
// and `name` includes the error name and error code as well which
// caused this test to break. Just changing the logic to check for
// string instead
t.equal((err.name.indexOf('AssertionError') >= 0), true);
t.equal(err.message, 'res.sendRaw() accepts only strings or buffers');
t.end();
});
Expand Down