Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
ignore invalid headers in mockResponseHeaders
Browse files Browse the repository at this point in the history
  • Loading branch information
winniehell committed Mar 4, 2016
1 parent 2fe55a5 commit dc67f0b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/mock/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ function mockResponseHeaders(req, res, next) {

if (res.swagger.headers) {
_.forEach(res.swagger.headers, function(header, name) {
if (!header) {
return;
}

// Set all HTTP headers that are defined in the Swagger API.
// If a default value is specified in the Swagger API, then use it; otherwise generate a value.
if (res.get(name) !== undefined) {
Expand All @@ -155,6 +159,10 @@ function mockResponseHeaders(req, res, next) {
util.debug(' %s: %s (default)', name, header.default);
}
else {
if (!name || !_.isFunction(name.toLowerCase)) {
return;
}

switch (name.toLowerCase()) {
case 'location':
res.location(req.baseUrl + (res.swagger.location || req.path));
Expand Down

0 comments on commit dc67f0b

Please sign in to comment.