Skip to content

Commit

Permalink
Fix missing status message in 0.10.
Browse files Browse the repository at this point in the history
  • Loading branch information
flatheadmill committed May 19, 2017
1 parent 2717d4e commit 51314fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 2 additions & 4 deletions reactor.js
Expand Up @@ -27,8 +27,6 @@ var coalesce = require('extant')
// Do nothing.
var nop = require('nop')

var MISSING = { 400: 'Bad Request', 500: 'Internal Server Error' }

function Constructor (object, dispatch) {
this._object = object
this._dispatch = dispatch
Expand Down Expand Up @@ -174,7 +172,7 @@ Reactor.prototype._respond = cadence(function (async, envelope) {

var result = vargs.shift()
var statusCode = (typeof vargs[0] == 'number') ? vargs.shift() : 200
var description = coalesce(http.STATUS_CODES[statusCode], MISSING[statusCode])
var description = coalesce(http.STATUS_CODES[statusCode])
if (typeof vargs[0] == 'string') {
description = vargs.shift()
}
Expand All @@ -192,7 +190,7 @@ Reactor.prototype._respond = cadence(function (async, envelope) {
try {
return rescue(/^reactor#http$/m, function (error) {
var statusCode = error.statusCode
var description = coalesce(error.description, http.STATUS_CODES[statusCode], MISSING[statusCode])
var description = coalesce(error.description, http.STATUS_CODES[statusCode])
var headers = coalesce(error.headers, {})

interrupt.assert(description != null, 'unknown.http.status', { statusCode: statusCode })
Expand Down
6 changes: 4 additions & 2 deletions t/reactor.t.js
Expand Up @@ -6,6 +6,7 @@ function prove (async, assert) {
var UserAgent = require('vizsla')
var http = require('http')
var connect = require('connect')
var coalesce = require('extant')

var now = 0
function Service () {
Expand Down Expand Up @@ -107,7 +108,8 @@ function prove (async, assert) {
ua.fetch(session, { url: '/exception' }, async())
}, function (body, response) {
assert(response.statusCode, 500, 'exception status code')
assert(response.statusMessage, 'Internal Server Error', 'exception status message')
// Node.js 0.10 does not parse the status messsage.
assert(coalesce(response.statusMessage, 'Internal Server Error'), 'Internal Server Error', 'exception status message')
ua.fetch(session, { url: '/json' }, async())
}, function (body, response) {
assert(body, { key: 'value' }, 'json')
Expand All @@ -117,7 +119,7 @@ function prove (async, assert) {
ua.fetch(session, { url: '/post', post: new Buffer('{') }, async())
}, function (body, response) {
assert(response.statusCode, 400, 'cannot parse')
assert(response.statusMessage, 'Bad Request', 'cannot parse message')
assert(coalesce(response.statusMessage, 'Bad Request'), 'Bad Request', 'cannot parse message')
ua.fetch(session, { url: '/callbacky' }, async())
}, function (body, response) {
assert(body.toString(), 'x\n', 'callbacky')
Expand Down

0 comments on commit 51314fa

Please sign in to comment.