Skip to content

Commit

Permalink
Merge 7d1e052 into cd17796
Browse files Browse the repository at this point in the history
  • Loading branch information
noodle committed Sep 6, 2018
2 parents cd17796 + 7d1e052 commit cda7907
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion legacy/http.framework.express.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@ HttpFrameworkExpress.prototype.addWrappedMethodFunction = function (method, midd
}

// merge default content-type with headers
res.writeHead(output.code, output.headers);
if (!res.headersSent) {
res.writeHead(output.code, output.headers);
}

if (Buffer.isBuffer(output.data)) {
res.end(output.data, 'binary');
Expand Down
5 changes: 5 additions & 0 deletions legacy/service.middleware/apiviewRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ var ApiViewRoutes = function (_ServiceMiddleware) {
}, {
key: '_handlerWrapper',
value: function _handlerWrapper(handlerFunc, resolved, skipOnError, service, controller, orgOutput) {
// do nothing if a response has already been sent
if (resolved['$rawResponse'].finished) {
return when.resolve({});
}

if (!orgOutput) {
orgOutput = { out: null, code: 200, headers: null };
}
Expand Down
4 changes: 3 additions & 1 deletion lib/http.framework.express.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ HttpFrameworkExpress.prototype.addWrappedMethodFunction = function (method, midd
}

// merge default content-type with headers
res.writeHead(output.code, output.headers);
if (!res.headersSent) {
res.writeHead(output.code, output.headers);
}

if (Buffer.isBuffer(output.data)) {
res.end(output.data, 'binary');
Expand Down
5 changes: 5 additions & 0 deletions lib/service.middleware/apiviewRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ class ApiViewRoutes extends ServiceMiddleware {

// TODO: to many input, need some work
_handlerWrapper (handlerFunc, resolved, skipOnError, service, controller, orgOutput) {
// do nothing if a response has already been sent
if (resolved['$rawResponse'].finished) {
return when.resolve({});
}

if (!orgOutput) {
orgOutput = { out: null, code: 200, headers: null };
}
Expand Down

0 comments on commit cda7907

Please sign in to comment.