Use accepts for negotiation

This commit is contained in:
Douglas Christopher Wilson
2014-05-29 14:37:29 -04:00
parent cb38e459ca
commit 7a2a8d2ecc
3 changed files with 6 additions and 6 deletions
+1
View File
@@ -5,6 +5,7 @@ unreleased
* Properly support all HTTP methods
* Support vanilla node.js http servers
* Treat `ENAMETOOLONG` as code 414
* Use accepts for negotiation
1.0.3 / 2014-05-20
==================
+3 -4
View File
@@ -14,6 +14,7 @@
* Module dependencies.
*/
var accepts = require('accepts');
var http = require('http')
, fs = require('fs')
, parse = require('url').parse
@@ -23,7 +24,6 @@ var http = require('http')
, extname = path.extname
, join = path.join;
var Batch = require('batch');
var Negotiator = require('negotiator');
/*!
* Icon cache.
@@ -130,9 +130,8 @@ exports = module.exports = function serveIndex(root, options){
files.sort();
// content-negotiation
var type = req.headers.accept === undefined
? mediaTypes[0]
: new Negotiator(req).preferredMediaType(mediaTypes);
var accept = accepts(req);
var type = accept.types(mediaTypes);
// not acceptable
if (!type) return next(createError(406));
+2 -2
View File
@@ -12,8 +12,8 @@
"url": "https://github.com/expressjs/serve-index/issues"
},
"dependencies": {
"batch": "0.5.0",
"negotiator": "0.4.3"
"accepts": "1.0.2",
"batch": "0.5.0"
},
"devDependencies": {
"istanbul": "0.2.10",