Skip to content

Commit 1cfefea

Browse files
authored
OutgoingMessage.prototype._headers is deprecated in Node.js 12. make sure res.getHeaders() exists for Node 6 (#430)
1 parent 7b46bf6 commit 1cfefea

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

app/steps/decorateUserResHeaders.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
function decorateUserResHeaders(container) {
55
var resolverFn = container.options.userResHeaderDecorator;
6-
var headers = container.user.res._headers;
6+
var headers = container.user.res.getHeaders ? container.user.res.getHeaders() : container.user.res._headers;
77

88
if (!resolverFn) {
99
return Promise.resolve(container);

test/userResDecorator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ describe('userResDecorator', function () {
160160

161161
proxyApp.use(proxy(redirectingServerOrigin, {
162162
userResDecorator: function (rsp, data, req, res) {
163-
var proxyReturnedLocation = res._headers.location;
163+
var proxyReturnedLocation = res.getHeaders ? res.getHeaders().location : res._headers.location;
164164
res.location(proxyReturnedLocation.replace(redirectingServerPort, preferredPort));
165165
return data;
166166
}

0 commit comments

Comments
 (0)