Comparing version 2.0.3 to 2.0.4
@@ -14,4 +14,4 @@ /** | ||
// create server | ||
function createServer(root, port){ | ||
http.createServer(function (request, response){ | ||
function createServer(root, port) { | ||
http.createServer(function(request, response) { | ||
var send = new FileSend(request, { | ||
@@ -24,10 +24,10 @@ root: root || '../', | ||
send.pipe(response).on('headers', function (headers){ | ||
var message = 'URL : ' + colors.green.bold(send.url) | ||
+ '\r\nPATH : ' + colors.yellow.bold(send.path) | ||
+ '\r\nROOT : ' + colors.magenta.bold(send.root) | ||
+ '\r\nREALPATH : ' + colors.magenta.bold(send.realpath) | ||
+ '\r\nSTATUS : ' + colors.cyan.bold(send.statusCode) | ||
+ '\r\nHEADERS : ' + colors.cyan.bold(JSON.stringify(headers, null, 2)) | ||
+ '\r\n-----------------------------------------------------------------------------------------'; | ||
send.pipe(response).on('headers', function(headers) { | ||
var message = 'URL : ' + colors.green.bold(send.url) + | ||
'\r\nPATH : ' + colors.yellow.bold(send.path) + | ||
'\r\nROOT : ' + colors.magenta.bold(send.root) + | ||
'\r\nREALPATH : ' + colors.magenta.bold(send.realpath) + | ||
'\r\nSTATUS : ' + colors.cyan.bold(send.statusCode) + | ||
'\r\nHEADERS : ' + colors.cyan.bold(JSON.stringify(headers, null, 2)) + | ||
'\r\n-----------------------------------------------------------------------------------------'; | ||
@@ -42,4 +42,4 @@ process.send(message); | ||
for (var i = 0; i < NUMCPUS; i++) { | ||
var worker = cluster.fork().on('listening', (function (i){ | ||
return function (address){ | ||
var worker = cluster.fork().on('listening', (function(i) { | ||
return function(address) { | ||
// worker is listening | ||
@@ -56,3 +56,3 @@ if (i === NUMCPUS - 1) { | ||
worker.on('message', function (message){ | ||
worker.on('message', function(message) { | ||
console.log(message); | ||
@@ -59,0 +59,0 @@ }); |
220
index.js
@@ -46,3 +46,3 @@ /*! | ||
// add http response write headers events | ||
http.ServerResponse.prototype.writeHead = function (){ | ||
http.ServerResponse.prototype.writeHead = function() { | ||
var context = this; | ||
@@ -66,3 +66,3 @@ | ||
*/ | ||
function FileSend(request, options){ | ||
function FileSend(request, options) { | ||
var context = this; | ||
@@ -84,5 +84,5 @@ | ||
context.method = context.request.method; | ||
context.charset = util.isType(options.charset, 'string') | ||
? options.charset | ||
: null; | ||
context.charset = util.isType(options.charset, 'string') ? | ||
options.charset : | ||
null; | ||
context.glob = options.glob || {}; | ||
@@ -101,3 +101,3 @@ | ||
enumerable: true, | ||
get: function (){ | ||
get: function() { | ||
if (!url) { | ||
@@ -115,7 +115,7 @@ url = util.decodeURI(request.url); | ||
enumerable: true, | ||
get: function (){ | ||
get: function() { | ||
if (!root) { | ||
root = util.isType(options.root, 'string') | ||
? resolve(options.root) | ||
: CWD; | ||
root = util.isType(options.root, 'string') ? | ||
resolve(options.root) : | ||
CWD; | ||
@@ -131,5 +131,5 @@ root = util.posixPath(join(root, SEP)); | ||
Object.defineProperty(context, '_url', { | ||
value: context.url === -1 | ||
? {} | ||
: parseUrl(context.url, options.parseQueryString, options.slashesDenoteHost) | ||
value: context.url === -1 ? | ||
{} : | ||
parseUrl(context.url, options.parseQueryString, options.slashesDenoteHost) | ||
}); | ||
@@ -140,14 +140,14 @@ | ||
enumerable: true, | ||
get: function (){ | ||
get: function() { | ||
if (!path) { | ||
var context = this; | ||
path = context.url === -1 | ||
? context.url | ||
: util.decodeURI(context._url.pathname); | ||
path = context.url === -1 ? | ||
context.url : | ||
util.decodeURI(context._url.pathname); | ||
// //a/b/c ==> /a/b/c | ||
path = path === -1 | ||
? path | ||
: path.replace(/^\/{2,}/, '/'); | ||
path = path === -1 ? | ||
path : | ||
path.replace(/^\/{2,}/, '/'); | ||
} | ||
@@ -162,9 +162,9 @@ | ||
enumerable: true, | ||
get: function (){ | ||
get: function() { | ||
if (!realpath) { | ||
var context = this; | ||
realpath = context.path === -1 | ||
? context.path | ||
: util.posixPath(join(context.root, context.path)); | ||
realpath = context.path === -1 ? | ||
context.path : | ||
util.posixPath(join(context.root, context.path)); | ||
} | ||
@@ -185,7 +185,7 @@ | ||
enumerable: true, | ||
get: function (){ | ||
get: function() { | ||
if (!etag) { | ||
etag = options.etag !== undefined | ||
? Boolean(options.etag) | ||
: true; | ||
etag = options.etag !== undefined ? | ||
Boolean(options.etag) : | ||
true; | ||
} | ||
@@ -200,9 +200,9 @@ | ||
enumerable: true, | ||
get: function (){ | ||
get: function() { | ||
if (!index) { | ||
index = Array.isArray(options.index) | ||
? options.index | ||
: [options.index]; | ||
index = Array.isArray(options.index) ? | ||
options.index : | ||
[options.index]; | ||
index = index.filter(function (index){ | ||
index = index.filter(function(index) { | ||
return index && util.isType(index, 'string'); | ||
@@ -219,13 +219,13 @@ }); | ||
enumerable: true, | ||
get: function (){ | ||
get: function() { | ||
if (!ignore) { | ||
ignore = Array.isArray(options.ignore) | ||
? options.ignore | ||
: [options.ignore]; | ||
ignore = Array.isArray(options.ignore) ? | ||
options.ignore : | ||
[options.ignore]; | ||
ignore = ignore.filter(function (pattern){ | ||
return pattern | ||
&& (util.isType(pattern, 'string') | ||
|| util.isType(pattern, 'regexp') | ||
|| util.isType(pattern, 'function')); | ||
ignore = ignore.filter(function(pattern) { | ||
return pattern && | ||
(util.isType(pattern, 'string') || | ||
util.isType(pattern, 'regexp') || | ||
util.isType(pattern, 'function')); | ||
}); | ||
@@ -241,3 +241,3 @@ } | ||
enumerable: true, | ||
get: function (){ | ||
get: function() { | ||
if (!ignoreAccess) { | ||
@@ -261,11 +261,11 @@ switch (options.ignoreAccess) { | ||
enumerable: true, | ||
get: function (){ | ||
get: function() { | ||
if (!maxAge) { | ||
maxAge = util.isType(options.maxAge, 'string') | ||
? ms(options.maxAge) / 1000 | ||
: Number(options.maxAge); | ||
maxAge = util.isType(options.maxAge, 'string') ? | ||
ms(options.maxAge) / 1000 : | ||
Number(options.maxAge); | ||
maxAge = !isNaN(maxAge) | ||
? Math.min(Math.max(0, maxAge), MAXMAXAGE) | ||
: 0; | ||
maxAge = !isNaN(maxAge) ? | ||
Math.min(Math.max(0, maxAge), MAXMAXAGE) : | ||
0; | ||
@@ -282,7 +282,7 @@ maxAge = Math.floor(maxAge); | ||
enumerable: true, | ||
get: function (){ | ||
get: function() { | ||
if (!lastModified) { | ||
lastModified = options.lastModified !== undefined | ||
? Boolean(options.lastModified) | ||
: true; | ||
lastModified = options.lastModified !== undefined ? | ||
Boolean(options.lastModified) : | ||
true; | ||
} | ||
@@ -332,7 +332,7 @@ | ||
*/ | ||
FileSend.prototype.isConditionalGET = function (){ | ||
FileSend.prototype.isConditionalGET = function() { | ||
var context = this; | ||
return !!(context.request.headers['if-none-match'] | ||
|| context.request.headers['if-modified-since']); | ||
return !!(context.request.headers['if-none-match'] || | ||
context.request.headers['if-modified-since']); | ||
}; | ||
@@ -346,7 +346,7 @@ | ||
*/ | ||
FileSend.prototype.isCachable = function (){ | ||
FileSend.prototype.isCachable = function() { | ||
var statusCode = this.statusCode; | ||
return statusCode === 304 | ||
|| (statusCode >= 200 && statusCode < 300); | ||
return statusCode === 304 || | ||
(statusCode >= 200 && statusCode < 300); | ||
}; | ||
@@ -359,3 +359,3 @@ | ||
*/ | ||
FileSend.prototype.isFresh = function (){ | ||
FileSend.prototype.isFresh = function() { | ||
var context = this; | ||
@@ -374,3 +374,3 @@ | ||
*/ | ||
FileSend.prototype.isRangeFresh = function (){ | ||
FileSend.prototype.isRangeFresh = function() { | ||
var context = this; | ||
@@ -383,5 +383,5 @@ var ifRange = context.request.headers['if-range']; | ||
return ifRange.indexOf('"') !== -1 | ||
? ifRange.indexOf(context.getHeader('ETag')) !== -1 | ||
: Date.parse(context.getHeader('Last-Modified')) <= Date.parse(ifRange); | ||
return ifRange.indexOf('"') !== -1 ? | ||
ifRange.indexOf(context.getHeader('ETag')) !== -1 : | ||
Date.parse(context.getHeader('Last-Modified')) <= Date.parse(ifRange); | ||
}; | ||
@@ -395,3 +395,3 @@ | ||
*/ | ||
FileSend.prototype.isIgnore = function (path){ | ||
FileSend.prototype.isIgnore = function(path) { | ||
var context = this; | ||
@@ -407,3 +407,3 @@ | ||
*/ | ||
FileSend.prototype.setHeader = function (name, value){ | ||
FileSend.prototype.setHeader = function(name, value) { | ||
var context = this; | ||
@@ -427,3 +427,3 @@ | ||
*/ | ||
FileSend.prototype.getHeader = function (name){ | ||
FileSend.prototype.getHeader = function(name) { | ||
var context = this; | ||
@@ -444,3 +444,3 @@ | ||
*/ | ||
FileSend.prototype.removeHeader = function (name){ | ||
FileSend.prototype.removeHeader = function(name) { | ||
var context = this; | ||
@@ -464,3 +464,3 @@ | ||
*/ | ||
FileSend.prototype.emit = function (event){ | ||
FileSend.prototype.emit = function(event) { | ||
var context = this; | ||
@@ -484,3 +484,3 @@ | ||
*/ | ||
FileSend.prototype.end = function (response, message){ | ||
FileSend.prototype.end = function(response, message) { | ||
// unpipe | ||
@@ -502,3 +502,3 @@ this._stream.unpipe(response); | ||
*/ | ||
FileSend.prototype.setHeaders = function (response, stats){ | ||
FileSend.prototype.setHeaders = function(response, stats) { | ||
var type; | ||
@@ -567,3 +567,3 @@ var context = this; | ||
*/ | ||
FileSend.prototype.parseRange = function (response, stats){ | ||
FileSend.prototype.parseRange = function(response, stats) { | ||
var start, end; | ||
@@ -611,3 +611,3 @@ var rangeFresh; | ||
// loop ranges | ||
ranges.forEach(function (range){ | ||
ranges.forEach(function(range) { | ||
var _boundary; | ||
@@ -620,5 +620,5 @@ | ||
// set fields | ||
_boundary = boundary + '\r\nContent-Range: ' | ||
+ 'bytes ' + start + '-' + end | ||
+ '/' + size + '\r\n\r\n'; | ||
_boundary = boundary + '\r\nContent-Range: ' + | ||
'bytes ' + start + '-' + end + | ||
'/' + size + '\r\n\r\n'; | ||
@@ -675,3 +675,3 @@ // set property | ||
*/ | ||
FileSend.prototype.status = function (response, statusCode, statusMessage){ | ||
FileSend.prototype.status = function(response, statusCode, statusMessage) { | ||
var context = this; | ||
@@ -693,3 +693,3 @@ | ||
*/ | ||
FileSend.prototype.error = function (response, statusCode, statusMessage){ | ||
FileSend.prototype.error = function(response, statusCode, statusMessage) { | ||
var context = this; | ||
@@ -707,3 +707,3 @@ | ||
// next method | ||
var next = function (message){ | ||
var next = function(message) { | ||
var context = this; | ||
@@ -737,3 +737,3 @@ | ||
*/ | ||
FileSend.prototype.statError = function (response, error){ | ||
FileSend.prototype.statError = function(response, error) { | ||
var context = this; | ||
@@ -756,3 +756,3 @@ | ||
*/ | ||
FileSend.prototype.dir = function (response, realpath, stats){ | ||
FileSend.prototype.dir = function(response, realpath, stats) { | ||
var context = this; | ||
@@ -763,3 +763,3 @@ | ||
if ( | ||
context.emit('dir', realpath, stats, function (message){ | ||
context.emit('dir', realpath, stats, function(message) { | ||
var context = this; | ||
@@ -784,3 +784,3 @@ | ||
*/ | ||
FileSend.prototype.redirect = function (response, location){ | ||
FileSend.prototype.redirect = function(response, location) { | ||
var context = this; | ||
@@ -812,3 +812,3 @@ | ||
*/ | ||
FileSend.prototype.headersSent = function (response){ | ||
FileSend.prototype.headersSent = function(response) { | ||
this.end(response, 'Can\'t set headers after they are sent.'); | ||
@@ -822,3 +822,3 @@ }; | ||
*/ | ||
FileSend.prototype.writeHead = function (response){ | ||
FileSend.prototype.writeHead = function(response) { | ||
var context = this; | ||
@@ -833,3 +833,3 @@ | ||
// set headers | ||
Object.keys(headers).forEach(function (name){ | ||
Object.keys(headers).forEach(function(name) { | ||
response.setHeader(name, headers[name]); | ||
@@ -844,3 +844,3 @@ }); | ||
*/ | ||
FileSend.prototype.createReadStream = function (response){ | ||
FileSend.prototype.createReadStream = function(response) { | ||
var context = this; | ||
@@ -857,3 +857,3 @@ var ranges = context.ranges; | ||
// stream error | ||
var onerror = function (error){ | ||
var onerror = function(error) { | ||
// request already finished | ||
@@ -870,3 +870,3 @@ if (onFinished.isFinished(response)) return; | ||
// contat range | ||
async.series(ranges, function (range, next){ | ||
async.series(ranges, function(range, next) { | ||
// request already finished | ||
@@ -882,3 +882,3 @@ if (onFinished.isFinished(response)) return; | ||
// error handling code-smell | ||
fileStream.on('error', function (error){ | ||
fileStream.on('error', function(error) { | ||
// call onerror | ||
@@ -891,3 +891,3 @@ onerror(error); | ||
// stream end | ||
fileStream.on('end', function (){ | ||
fileStream.on('end', function() { | ||
// unpipe | ||
@@ -905,3 +905,3 @@ fileStream.unpipe(stream); | ||
fileStream.pipe(stream, { end: false }); | ||
}, function (){ | ||
}, function() { | ||
var range = ranges[ranges.length - 1]; | ||
@@ -923,9 +923,9 @@ | ||
*/ | ||
FileSend.prototype.readIndex = function (response, stats){ | ||
FileSend.prototype.readIndex = function(response, stats) { | ||
var context = this; | ||
var path = context.hasTrailingSlash ? context.path : context.path + '/'; | ||
async.series(context.index.map(function (index){ | ||
async.series(context.index.map(function(index) { | ||
return path + index; | ||
}), function (path, next){ | ||
}), function(path, next) { | ||
var context = this; | ||
@@ -937,3 +937,3 @@ | ||
fs.stat(join(context.root, path), function (error, stats){ | ||
fs.stat(join(context.root, path), function(error, stats) { | ||
if (error || !stats.isFile()) { | ||
@@ -945,3 +945,3 @@ next(); | ||
}.bind(context)); | ||
}, function (){ | ||
}, function() { | ||
var context = this; | ||
@@ -962,3 +962,3 @@ | ||
*/ | ||
FileSend.prototype.read = function (response){ | ||
FileSend.prototype.read = function(response) { | ||
var context = this; | ||
@@ -968,3 +968,3 @@ | ||
if (response.headersSent) { | ||
return process.nextTick(function (){ | ||
return process.nextTick(function() { | ||
this.headersSent(response); | ||
@@ -979,3 +979,3 @@ }.bind(context)); | ||
if (context.realpath === -1 || context.realpath.indexOf('\0') !== -1) { | ||
return process.nextTick(function (){ | ||
return process.nextTick(function() { | ||
this.error(response, 400); | ||
@@ -987,3 +987,3 @@ }.bind(context)); | ||
if (util.isOutBound(context.realpath, context.root)) { | ||
return process.nextTick(function (){ | ||
return process.nextTick(function() { | ||
this.error(response, 403); | ||
@@ -997,7 +997,7 @@ }.bind(context)); | ||
case 'deny': | ||
return process.nextTick(function (){ | ||
return process.nextTick(function() { | ||
this.error(response, 403); | ||
}.bind(context)); | ||
case 'ignore': | ||
return process.nextTick(function (){ | ||
return process.nextTick(function() { | ||
this.error(response, 404); | ||
@@ -1009,3 +1009,3 @@ }.bind(context)); | ||
// read | ||
fs.stat(context.realpath, function (error, stats){ | ||
fs.stat(context.realpath, function(error, stats) { | ||
var context = this; | ||
@@ -1061,3 +1061,3 @@ | ||
*/ | ||
FileSend.prototype.pipe = function (response){ | ||
FileSend.prototype.pipe = function(response) { | ||
var context = this; | ||
@@ -1067,3 +1067,3 @@ | ||
// bind error event | ||
context._stream.on('error', function (error){ | ||
context._stream.on('error', function(error) { | ||
this.statError(response, error); | ||
@@ -1073,3 +1073,3 @@ }.bind(context)); | ||
// bind headers event | ||
response.on('headers', function (){ | ||
response.on('headers', function() { | ||
this.writeHead(response); | ||
@@ -1079,3 +1079,3 @@ }.bind(context)); | ||
// response finished | ||
onFinished(response, function (){ | ||
onFinished(response, function() { | ||
// emit finish event | ||
@@ -1088,3 +1088,3 @@ this.emit('finish'); | ||
} else { | ||
context._stream.on('error', function (error){ | ||
context._stream.on('error', function(error) { | ||
response.emit('error', error); | ||
@@ -1091,0 +1091,0 @@ }.bind(context)); |
@@ -17,3 +17,3 @@ /*! | ||
*/ | ||
function Iterator(array){ | ||
function Iterator(array) { | ||
this.index = 0; | ||
@@ -27,3 +27,3 @@ this.array = Array.isArray(array) ? array : []; | ||
*/ | ||
Iterator.prototype.next = function (){ | ||
Iterator.prototype.next = function() { | ||
var done = this.index >= this.array.length; | ||
@@ -43,3 +43,3 @@ var value = !done ? this.array[this.index++] : undefined; | ||
Iterator: Iterator, | ||
series: function (array, iterator, done, context){ | ||
series: function(array, iterator, done, context) { | ||
// create a new iterator | ||
@@ -58,3 +58,3 @@ var it = new Iterator(array); | ||
*/ | ||
function walk(it){ | ||
function walk(it) { | ||
var item = it.next(); | ||
@@ -65,3 +65,3 @@ | ||
} else { | ||
iterator(item.value, function (){ | ||
iterator(item.value, function() { | ||
walk(it); | ||
@@ -68,0 +68,0 @@ }); |
@@ -21,3 +21,3 @@ /*! | ||
*/ | ||
function DestroyableTransform(options){ | ||
function DestroyableTransform(options) { | ||
Transform.call(this, options); | ||
@@ -38,3 +38,3 @@ | ||
*/ | ||
DestroyableTransform.prototype.destroy = function (error){ | ||
DestroyableTransform.prototype.destroy = function(error) { | ||
if (this._destroyed) return; | ||
@@ -46,3 +46,3 @@ | ||
process.nextTick(function (){ | ||
process.nextTick(function() { | ||
if (error) self.emit('error', error); | ||
@@ -60,3 +60,3 @@ | ||
*/ | ||
function noop(chunk, encoding, next){ | ||
function noop(chunk, encoding, next) { | ||
next(null, chunk); | ||
@@ -71,4 +71,4 @@ } | ||
*/ | ||
function through(construct){ | ||
return function (options, transform, flush){ | ||
function through(construct) { | ||
return function(options, transform, flush) { | ||
if (util.isType(options, 'function')) { | ||
@@ -90,3 +90,3 @@ flush = transform; | ||
*/ | ||
module.exports = through(function (options, transform, flush){ | ||
module.exports = through(function(options, transform, flush) { | ||
options = options || {}; | ||
@@ -93,0 +93,0 @@ options.objectMode = options.objectMode || false; |
@@ -33,3 +33,3 @@ /*! | ||
*/ | ||
isType: function (value, type){ | ||
isType: function(value, type) { | ||
// format type | ||
@@ -51,3 +51,3 @@ type = (type + '').toLowerCase(); | ||
return realType === '[object number]' && value !== value; | ||
default : | ||
default: | ||
// other | ||
@@ -64,3 +64,3 @@ return realType === '[object ' + type + ']'; | ||
*/ | ||
isOutBound: function (path, root){ | ||
isOutBound: function(path, root) { | ||
if (process.platform === 'win32') { | ||
@@ -82,3 +82,3 @@ path = path.toLowerCase(); | ||
*/ | ||
normalize: function (path){ | ||
normalize: function(path) { | ||
// \a\b\.\c\.\d ==> /a/b/./c/./d | ||
@@ -113,3 +113,3 @@ path = path.replace(BACKSLASH_RE, '/'); | ||
*/ | ||
posixPath: function (path){ | ||
posixPath: function(path) { | ||
return path.replace(BACKSLASH_RE, '/'); | ||
@@ -123,3 +123,3 @@ }, | ||
*/ | ||
decodeURI: function (uri){ | ||
decodeURI: function(uri) { | ||
try { | ||
@@ -136,3 +136,3 @@ return decodeURIComponent(uri); | ||
*/ | ||
boundaryGenerator: function (){ | ||
boundaryGenerator: function() { | ||
var boundary = ''; | ||
@@ -139,0 +139,0 @@ |
{ | ||
"name": "file-send", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "A http file send", | ||
@@ -32,3 +32,3 @@ "author": { | ||
"dependencies": { | ||
"ms": "^0.7.1", | ||
"ms": "^0.7.2", | ||
"etag": "^1.7.0", | ||
@@ -49,3 +49,3 @@ "fresh": "^0.3.0", | ||
"chai": "^3.5.0", | ||
"superagent": "^2.2.0" | ||
"superagent": "^2.3.0" | ||
}, | ||
@@ -52,0 +52,0 @@ "readmeFilename": "README.md", |
@@ -27,3 +27,3 @@ file-send | ||
http.createServer(function (request, response){ | ||
http.createServer(function(request, response) { | ||
FileSend(request, { | ||
@@ -34,12 +34,12 @@ root: '/', | ||
}) // Create a new file send stream | ||
.on('headers', function(headers){ | ||
.on('headers', function(headers) { | ||
// headers events | ||
}) | ||
.on('dir', function(realpath, stats, next){ | ||
.on('dir', function(realpath, stats, next) { | ||
// dir events | ||
}) | ||
.on('error', function(error, next){ | ||
.on('error', function(error, next) { | ||
// error events | ||
}) | ||
.on('finish', function(headers){ | ||
.on('finish', function(headers) { | ||
// finish events | ||
@@ -141,3 +141,3 @@ }) | ||
var http = require('http'); | ||
var FileSend = require('file-send'); | ||
var FileSend = require('../index'); | ||
var colors = require('colors/safe'); | ||
@@ -148,6 +148,6 @@ var cluster = require('cluster'); | ||
// create server | ||
function createServer(root, port){ | ||
http.createServer(function (request, response){ | ||
function createServer(root, port) { | ||
http.createServer(function(request, response) { | ||
var send = new FileSend(request, { | ||
root: root || './', | ||
root: root || '../', | ||
maxAge: '3day', | ||
@@ -158,10 +158,10 @@ ignore: ['/**/.*?(/*.*|/)'], | ||
send.pipe(response).on('headers', function (headers){ | ||
var message = 'URL : ' + colors.green.bold(send.url) | ||
+ '\r\nPATH : ' + colors.yellow.bold(send.path) | ||
+ '\r\nROOT : ' + colors.magenta.bold(send.root) | ||
+ '\r\nREALPATH : ' + colors.magenta.bold(send.realpath) | ||
+ '\r\nSTATUS : ' + colors.cyan.bold(send.statusCode) | ||
+ '\r\nHEADERS : ' + colors.cyan.bold(JSON.stringify(headers, null, 2)) | ||
+ '\r\n-----------------------------------------------------------------------------------------'; | ||
send.pipe(response).on('headers', function(headers) { | ||
var message = 'URL : ' + colors.green.bold(send.url) + | ||
'\r\nPATH : ' + colors.yellow.bold(send.path) + | ||
'\r\nROOT : ' + colors.magenta.bold(send.root) + | ||
'\r\nREALPATH : ' + colors.magenta.bold(send.realpath) + | ||
'\r\nSTATUS : ' + colors.cyan.bold(send.statusCode) + | ||
'\r\nHEADERS : ' + colors.cyan.bold(JSON.stringify(headers, null, 2)) + | ||
'\r\n-----------------------------------------------------------------------------------------'; | ||
@@ -176,4 +176,4 @@ process.send(message); | ||
for (var i = 0; i < NUMCPUS; i++) { | ||
var worker = cluster.fork().on('listening', (function (i){ | ||
return function (address){ | ||
var worker = cluster.fork().on('listening', (function(i) { | ||
return function(address) { | ||
// worker is listening | ||
@@ -190,3 +190,3 @@ if (i === NUMCPUS - 1) { | ||
worker.on('message', function (message){ | ||
worker.on('message', function(message) { | ||
console.log(message); | ||
@@ -193,0 +193,0 @@ }); |
41706
10
Updatedms@^0.7.2