mirror of
https://github.com/zebrajr/express.git
synced 2025-12-06 12:19:51 +01:00
Use http-errors for res.format error
This commit is contained in:
parent
5855339455
commit
a10770286e
|
|
@ -8,6 +8,7 @@ unreleased
|
|||
* Ignore `Object.prototype` values in settings through `app.set`/`app.get`
|
||||
* Invoke `default` with same arguments as types in `res.format`
|
||||
* Support proper 205 responses using `res.send`
|
||||
* Use `http-errors` for `res.format` error
|
||||
* deps: depd@2.0.0
|
||||
- Replace internal `eval` usage with `Function` constructor
|
||||
- Use instance methods on `process` to check for listeners
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var contentDisposition = require('content-disposition');
|
||||
var createError = require('http-errors')
|
||||
var deprecate = require('depd')('express');
|
||||
var encodeUrl = require('encodeurl');
|
||||
var escapeHtml = require('escape-html');
|
||||
|
|
@ -699,10 +700,9 @@ res.format = function(obj){
|
|||
} else if (obj.default) {
|
||||
obj.default(req, this, next)
|
||||
} else {
|
||||
var err = new Error('Not Acceptable');
|
||||
err.status = err.statusCode = 406;
|
||||
err.types = normalizeTypes(keys).map(function(o){ return o.value });
|
||||
next(err);
|
||||
next(createError(406, {
|
||||
types: normalizeTypes(keys).map(function (o) { return o.value })
|
||||
}))
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
"etag": "~1.8.1",
|
||||
"finalhandler": "1.2.0",
|
||||
"fresh": "0.5.2",
|
||||
"http-errors": "2.0.0",
|
||||
"merge-descriptors": "1.0.1",
|
||||
"methods": "~1.1.2",
|
||||
"on-finished": "~2.3.0",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user