Skip to content
Myr

Add res.sendStatus

Before adoption: this commit came in with the history the project adopted, so no landing records it.

closes #2269 closes #2297 closes #2340

authored by Seth Samuel · committed by Douglas Christopher Wilson · parent 51d33ed · Browse files · 3 files+57 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+57 added−0 removed

  • tests:+32 added−0 removed
  • other:+25 added−0 removed

3 files+57 added−0 removed

modified:lib/response.js+24 added
302 unmodified lines
303 return this.send(body);304};305306/**307 * Send given HTTP status code.308 *309 * Sets the response status to `statusCode` and the body of the310 * response to the standard description from node's http.STATUS_CODES311 * or the statusCode number if no description.312 *313 * Examples:314 *315 * res.sendStatus(200);316 *317 * @param {number} statusCode318 * @api public319 */320321res.sendStatus = function sendStatus(statusCode) {322 var body = http.STATUS_CODES[statusCode] || String(statusCode);323324 this.statusCode = statusCode;325 this.type('txt');326327 return this.send(body);328};329330/**331 * Transfer the file at the given `path`.332 *333 * Automatically sets the _Content-Type_ response header field.334 * The callback `fn(err)` is invoked when the transfer is complete
633 unmodified lines
added:test/res.sendStatus.js+32 added
modified:History.md+1 added
1unreleased2==========34 * Add `res.sendStatus`5 * Invoke callback for sendfile when client aborts6 - Applies to `res.sendFile`, `res.sendfile`, and `res.download`7 - `err` will be populated with request aborted error8 * Support IP address host in `req.subdomains`
2215 unmodified lines