Skip to content

Commit

Permalink
Fix for missing statusCode in 0.10 JWRs
Browse files Browse the repository at this point in the history
  • Loading branch information
mikermcneil committed Mar 18, 2014
1 parent a589a8f commit 7a260b3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
7 changes: 0 additions & 7 deletions lib/hooks/blueprints/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ module.exports = function(sails) {
// Whether to run `Model.watch()` in the `find` blueprint action.
autoWatch: false,

// Whether to send various aspects of an emulated HTTP response
// down with responses originated from socket requests.
sockets: {
sendResponseHeaders: true,
sendStatusCode: true
}


// (TODO: generated comments for jsonp configuration needs to be updated w/ new options)
// (TODO: need to mention new `req.options` stuff in generated comments)
Expand Down
7 changes: 7 additions & 0 deletions lib/hooks/sockets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ module.exports = function(sails) {
// Socket.io configuration
sockets: {

// Whether to send various aspects of an emulated HTTP response
// down in the JWR originated from each socket request.
// (doesn't affect direct socket.io usage-- only if you're using
// the Sails SDK and therefore the request interpreter)
sendResponseHeaders: true,
sendStatusCode: true,

// Default behavior is a noop
// Code to run when a new socket connects
onConnect: function (session, socket) {},
Expand Down
10 changes: 5 additions & 5 deletions lib/hooks/sockets/interpreter/interpret.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ module.exports = function (sails) {

// Allow headers and status code to be disabled to allow for squeezing
// out a little more performance when relevant (and reducing bandwidth usage).
// To achieve this, set `req.options.sockets.sendResponseHeaders=false` and/or
// `req.options.sockets.sendStatusCode=false`.
if ( typeof req.options.sockets === 'object' ) {
if (req.options.sockets.sendResponseHeaders) {
// To achieve this, set `sails.config.sockets.sendResponseHeaders=false` and/or
// `sails.config.sockets.sendStatusCode=false`.
if ( typeof sails.config.sockets === 'object' ) {
if (sails.config.sockets.sendResponseHeaders) {
responseCtx.headers = res.headers;
}
if (req.options.sockets.sendStatusCode) {
if (sails.config.sockets.sendStatusCode) {
responseCtx.statusCode = res.statusCode;
}
}
Expand Down

0 comments on commit 7a260b3

Please sign in to comment.