node-static
Advanced tools
Comparing version 0.7.9 to 0.7.10
#!/usr/bin/env node | ||
var fs = require('fs'), | ||
path = require('path'), | ||
tty = require('tty'), | ||
@@ -6,0 +5,0 @@ statik = require('./../lib/node-static'); |
@@ -195,3 +195,3 @@ var fs = require('fs') | ||
*/ | ||
Server.prototype.gzipOk = function(req, contentType) { | ||
Server.prototype.gzipOk = function (req, contentType) { | ||
var enable = this.options.gzip; | ||
@@ -210,16 +210,13 @@ if(enable && | ||
*/ | ||
Server.prototype.respondGzip = function(pathname, status, contentType, _headers, files, stat, req, res, finish) { | ||
Server.prototype.respondGzip = function (pathname, status, contentType, _headers, files, stat, req, res, finish) { | ||
var that = this; | ||
if(files.length == 1 && this.gzipOk(req, contentType)) { | ||
if (files.length == 1 && this.gzipOk(req, contentType)) { | ||
var gzFile = files[0] + ".gz"; | ||
fs.stat(gzFile, function(e, gzStat) { | ||
if(!e && gzStat.isFile()) { | ||
//console.log('Serving', gzFile, 'to gzip-capable client instead of', files[0], 'new size is', gzStat.size, 'uncompressed size', stat.size); | ||
fs.stat(gzFile, function (e, gzStat) { | ||
if (!e && gzStat.isFile()) { | ||
var vary = _headers['Vary']; | ||
_headers['Vary'] = (vary && vary != 'Accept-Encoding'?vary+', ':'')+'Accept-Encoding'; | ||
_headers['Vary'] = (vary && vary != 'Accept-Encoding' ? vary + ', ' : '') + 'Accept-Encoding'; | ||
_headers['Content-Encoding'] = 'gzip'; | ||
stat.size = gzStat.size; | ||
files = [gzFile]; | ||
} else { | ||
//console.log('gzip file not found or error finding it', gzFile, String(e), stat.isFile()); | ||
} | ||
@@ -234,3 +231,3 @@ that.respondNoGzip(pathname, status, contentType, _headers, files, stat, req, res, finish); | ||
Server.prototype.parseByteRange = function(req, stat) { | ||
Server.prototype.parseByteRange = function (req, stat) { | ||
var byteRange = { | ||
@@ -334,3 +331,3 @@ from: 0, | ||
'Expires', | ||
'Last-Modified'].forEach(function(entityHeader) { | ||
'Last-Modified'].forEach(function (entityHeader) { | ||
delete headers[entityHeader]; | ||
@@ -340,3 +337,2 @@ }); | ||
} else { | ||
res.writeHead(status, headers); | ||
@@ -343,0 +339,0 @@ |
@@ -11,3 +11,3 @@ { | ||
], | ||
"author": "Alexis Sellier <self@cloudhead.net>", | ||
"author": "Alexis Sellier <alexis@cloudhead.io>", | ||
"contributors": [ | ||
@@ -32,3 +32,3 @@ "Pablo Cantero <pablo@pablocantero.com>", | ||
"colors": ">=0.6.0", | ||
"mime": ">=1.2.9" | ||
"mime": "^1.2.9" | ||
}, | ||
@@ -39,3 +39,3 @@ "devDependencies": { | ||
}, | ||
"version": "0.7.9", | ||
"version": "0.7.10", | ||
"engines": { | ||
@@ -42,0 +42,0 @@ "node": ">= 0.4.1" |
42082
14
882
+ Addedmime@1.6.0(transitive)
- Removedmime@4.0.6(transitive)
Updatedmime@^1.2.9