Use content-type to parse Content-Type headers

This commit is contained in:
Douglas Christopher Wilson
2015-02-17 22:49:24 -05:00
parent 69a4869db0
commit f22937f3d1
3 changed files with 16 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
3.x
===
* Use `content-type` to parse `Content-Type` headers
* deps: connect@2.29.0
- Use `content-type` to parse `Content-Type` headers
- deps: body-parser@~1.12.0

View File

@@ -1,12 +1,19 @@
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module dependencies.
* @api private
*/
var contentType = require('content-type');
var etag = require('etag');
var mime = require('connect').mime;
var proxyaddr = require('proxy-addr');
var typer = require('media-typer');
/**
* toString ref.
@@ -393,15 +400,17 @@ exports.compileTrust = function(val) {
* @api private
*/
exports.setCharset = function(type, charset){
if (!type || !charset) return type;
exports.setCharset = function setCharset(type, charset) {
if (!type || !charset) {
return type;
}
// parse type
var parsed = typer.parse(type);
var parsed = contentType.parse(type);
// set charset
parsed.parameters.charset = charset;
// format type
return typer.format(parsed);
return contentType.format(parsed);
};

View File

@@ -29,6 +29,7 @@
"basic-auth": "1.0.0",
"connect": "2.29.0",
"content-disposition": "0.5.0",
"content-type": "~1.0.1",
"commander": "2.6.0",
"cookie-signature": "1.0.6",
"debug": "~2.1.1",
@@ -36,7 +37,6 @@
"escape-html": "1.0.1",
"etag": "~1.5.1",
"fresh": "0.2.4",
"media-typer": "0.3.0",
"methods": "~1.1.1",
"mkdirp": "0.5.0",
"parseurl": "~1.3.0",