Skip to content

Commit

Permalink
Avoid setting empty response headers
Browse files Browse the repository at this point in the history
Fixes #804 for v5.x.x
  • Loading branch information
jormaechea authored and dnalborczyk committed Sep 11, 2019
1 parent cfe1d54 commit 636af2a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/ApiGateway.js
Expand Up @@ -664,9 +664,6 @@ module.exports = class ApiGateway {
: result
);
if(typeof headerValue === 'undefined' || headerValue === null) {
debugLog(
`Warning: empty value for responseParameter "${key}": "${value}"`,
);
headerValue = '';
} else {
headerValue = headerValue.toString();
Expand All @@ -688,10 +685,16 @@ module.exports = class ApiGateway {
: value; // See #34
}
// Applies the header;
debugLog(
`Will assign "${headerValue}" to header "${headerName}"`,
);
response.header(headerName, headerValue);
if (headerValue === '') {
this.serverlessLog(
`Warning: empty value for responseParameter "${key}": "${value}", it won't be set`,
);
} else {
debugLog(
`Will assign "${headerValue}" to header "${headerName}"`,
);
response.header(headerName, headerValue);
}
} else {
this.printBlankLine();
this.serverlessLog(
Expand Down

0 comments on commit 636af2a

Please sign in to comment.