Deprecate combined status, response signatures
Before adoption: this commit came in with the history the project adopted, so no landing records it.
closes #2227
authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent 21bb2ef · Browse files · 2 files·+13 added−17 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+13 added−17 removed
- other:+13 added−17 removed
Provenance
- Commit
fd3b405- Tree
c8d7d2b- Author
Douglas Christopher Wilson <doug@somethingdoug.com>- Committer
Douglas Christopher Wilson <doug@somethingdoug.com>- Parent
21bb2ef
2 files changed+13 added−17 removed
modified:lib/response.js+10 added-17 removed
70 unmodified lines71 *72 * res.send(new Buffer('wahoo'));73 * res.send({ some: 'json' });74 * res.send('<p>some html</p>');75- * res.send(404, 'Sorry, cant find that');76- * res.send(404);75 *76+ * @param {string|number|boolean|object|Buffer} body77 * @api public78 */79 80 res.send = function send(body) {9 unmodified lines90 // allow status / body91 if (arguments.length === 2) {92 // res.send(body, status) backwards compat93 if (typeof arguments[0] !== 'number' && typeof arguments[1] === 'number') {95- deprecate('res.send(body, status): Use res.send(status, body) instead');94+ deprecate('res.send(body, status): Use res.status(status).send(body) instead');95 this.statusCode = arguments[1];96 } else {97+ deprecate('res.send(status, body): Use res.status(status).send(body) instead');98 this.statusCode = arguments[0];99 chunk = arguments[1];100 }101 }4 unmodified lines106 if (!this.get('Content-Type')) {107 this.type('txt');108 }109 110+ deprecate('res.send(status): Use res.status(status).end() instead');111 this.statusCode = chunk;112 chunk = http.STATUS_CODES[chunk];113 }114 82 unmodified lines197 * Examples:198 *199 * res.json(null);200 * res.json({ user: 'tj' });200- * res.json(500, 'oh noes!');201- * res.json(404, 'I dont have that');201 *202+ * @param {string|number|boolean|object} obj203 * @api public204 */205 206 res.json = function json(obj) {2 unmodified lines209 // allow status / body210 if (arguments.length === 2) {211 // res.json(body, status) backwards compat212 if (typeof arguments[1] === 'number') {213+ deprecate('res.json(obj, status): Use res.status(status).json(obj) instead');214 this.statusCode = arguments[1];214- if (typeof arguments[0] === 'number') {215- deprecate('res.json(obj, status): Use res.json(status, obj) instead');216- } else {217- deprecate('res.json(num, status): Use res.status(status).json(num) instead');218- }215 } else {216+ deprecate('res.json(status, obj): Use res.status(status).json(obj) instead');217 this.statusCode = arguments[0];218 val = arguments[1];219 }220 }18 unmodified lines239 * Examples:240 *241 * res.jsonp(null);242 * res.jsonp({ user: 'tj' });246- * res.jsonp(500, 'oh noes!');247- * res.jsonp(404, 'I dont have that');243 *244+ * @param {string|number|boolean|object} obj245 * @api public246 */247 248 res.jsonp = function jsonp(obj) {2 unmodified lines251 // allow status / body252 if (arguments.length === 2) {253 // res.json(body, status) backwards compat254 if (typeof arguments[1] === 'number') {255+ deprecate('res.jsonp(obj, status): Use res.status(status).json(obj) instead');256 this.statusCode = arguments[1];260- if (typeof arguments[0] === 'number') {261- deprecate('res.jsonp(obj, status): Use res.jsonp(status, obj) instead');262- } else {263- deprecate('res.jsonp(num, status): Use res.status(status).jsonp(num) instead');264- }257 } else {258+ deprecate('res.jsonp(status, obj): Use res.status(status).jsonp(obj) instead');259 this.statusCode = arguments[0];260 val = arguments[1];261 }262 }572 unmodified linesmodified:History.md+3 added
4 unmodified lines5 - `app.set('query parser', 'extended')` parse with "qs" module6 - `app.set('query parser', 'simple')` parse with "querystring" core module7 - `app.set('query parser', false)` disable query string parsing8 - `app.set('query parser', true)` enable simple parsing9+ * deprecate `res.json(status, obj)` -- use `res.status(status).json(obj)` instead10+ * deprecate `res.jsonp(status, obj)` -- use `res.status(status).jsonp(obj)` instead11+ * deprecate `res.send(status, body)` -- use `res.status(status).send(body)` instead12 * deps: debug@1.0.413 * deps: finalhandler@0.1.014 - Respond after request fully read15 - deps: debug@1.0.41810 unmodified lines