response.js
This file
Path
lib/response.js
998 lines · 22.2 KiB · JavaScript
Last changed by
Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
History of this fileTake it
The walk stopped after 200 commits: lines older than 8ba3f39 point at it.
Merge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710
lines 1–7why, one step back1/*!2 * express3 * Copyright(c) 2009-2013 TJ Holowaychuk4 * Copyright(c) 2014-2015 Douglas Christopher Wilson5 * MIT Licensed6 */7Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 8–9why, one step back8'use strict';94.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 10–11why, one step back10/**11 * Module dependencies.Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 12why, one step back12 * @private4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 13–14why, one step back13 */14Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
line 15why, one step back15var Buffer = require('safe-buffer').BufferUse content-disposition moduleDouglas Christopher Wilsonbefore adoption6f31218
line 16why, one step back16var contentDisposition = require('content-disposition');Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
line 17why, one step back17var encodeUrl = require('encodeurl');4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 18–19why, one step back18var escapeHtml = require('escape-html');19var http = require('http');Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 20why, one step back20var onFinished = require('on-finished');4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
line 21why, one step back21var path = require('path');Use path-is-absolute module for absolute path detectionJeremiah Senkpielbefore adoption694869d
line 22why, one step back22var pathIsAbsolute = require('path-is-absolute');Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
line 23why, one step back23var statuses = require('statuses')Merge tag '3.18.1'Douglas Christopher Wilsonbefore adoptionccc45a7
line 24why, one step back24var merge = require('utils-merge');4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 25–32why, one step back25var sign = require('cookie-signature').sign;26var normalizeType = require('./utils').normalizeType;27var normalizeTypes = require('./utils').normalizeTypes;28var setCharset = require('./utils').setCharset;29var cookie = require('cookie');30var send = require('send');31var extname = path.extname;32var mime = send.mime;Fix incorrect deprecation warnings on res.downloadDouglas Christopher Wilsonbefore adoption1150ca7
line 33why, one step back33var resolve = path.resolve;4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 34–37why, one step back34var vary = require('vary');3536/**37 * Response prototype.Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
line 38why, one step back38 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 39–40why, one step back39 */40Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
line 41why, one step back41var res = Object.create(http.ServerResponse.prototype)4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 42–43why, one step back4243/**Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 44–50why, one step back44 * Module exports.45 * @public46 */4748module.exports = res4950/**Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 51–57why, one step back51 * Module variables.52 * @private53 */5455var charsetRegExp = /;\s*charset\s*=/;5657/**4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 58–61why, one step back58 * Set status `code`.59 *60 * @param {Number} code61 * @return {ServerResponse}Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 62why, one step back62 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 63–64why, one step back63 */64Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 65why, one step back65res.status = function status(code) {4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 66–81why, one step back66 this.statusCode = code;67 return this;68};6970/**71 * Set Link header field with the given `links`.72 *73 * Examples:74 *75 * res.links({76 * next: 'http://api.example.com/users?page=2',77 * last: 'http://api.example.com/users?page=5'78 * });79 *80 * @param {Object} links81 * @return {ServerResponse}Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 82why, one step back82 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 83–97why, one step back83 */8485res.links = function(links){86 var link = this.get('Link') || '';87 if (link) link += ', ';88 return this.set('Link', link + Object.keys(links).map(function(rel){89 return '<' + links[rel] + '>; rel="' + rel + '"';90 }).join(', '));91};9293/**94 * Send a response.95 *96 * Examples:97 *Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
line 98why, one step back98 * res.send(Buffer.from('wahoo'));4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 99–101why, one step back99 * res.send({ some: 'json' });100 * res.send('<p>some html</p>');101 *Deprecate combined status, response signaturesDouglas Christopher Wilsonbefore adoptionfd3b405
line 102why, one step back102 * @param {string|number|boolean|object|Buffer} bodyMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 103why, one step back103 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 104–147why, one step back104 */105106res.send = function send(body) {107 var chunk = body;108 var encoding;109 var req = this.req;110 var type;111112 // settings113 var app = this.app;114115 switch (typeof chunk) {116 // string defaulting to html117 case 'string':118 if (!this.get('Content-Type')) {119 this.type('html');120 }121 break;122 case 'boolean':123 case 'number':124 case 'object':125 if (chunk === null) {126 chunk = '';127 } else if (Buffer.isBuffer(chunk)) {128 if (!this.get('Content-Type')) {129 this.type('bin');130 }131 } else {132 return this.json(chunk);133 }134 break;135 }136137 // write strings in utf-8138 if (typeof chunk === 'string') {139 encoding = 'utf8';140 type = this.get('Content-Type');141142 // reflect this in content-type143 if (typeof type === 'string') {144 this.set('Content-Type', setCharset(type, 'utf-8'));145 }146 }147Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
lines 148–151why, one step back148 // determine if ETag should be generated149 var etagFn = app.get('etag fn')150 var generateETag = !this.get('ETag') && typeof etagFn === 'function'1514.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
line 152why, one step back152 // populate Content-LengthMerge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
line 153why, one step back153 var lenperf: prevent multiple Buffer creation in res.sendDouglas Christopher Wilsonbefore adoptionb43205c
line 154why, one step back154 if (chunk !== undefined) {Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
lines 155–163why, one step back155 if (Buffer.isBuffer(chunk)) {156 // get length of Buffer157 len = chunk.length158 } else if (!generateETag && chunk.length < 1000) {159 // just calculate length when no ETag + small chunk160 len = Buffer.byteLength(chunk, encoding)161 } else {162 // convert chunk to Buffer and calculate163 chunk = Buffer.from(chunk, encoding)perf: prevent multiple Buffer creation in res.sendDouglas Christopher Wilsonbefore adoptionb43205c
line 164why, one step back164 encoding = undefined;Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
line 165why, one step back165 len = chunk.lengthperf: prevent multiple Buffer creation in res.sendDouglas Christopher Wilsonbefore adoptionb43205c
lines 166–167why, one step back166 }1674.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 168–170why, one step back168 this.set('Content-Length', len);169 }170Merge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710
lines 171–172why, one step back171 // populate ETag172 var etag;Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
lines 173–174why, one step back173 if (generateETag && len !== undefined) {174 if ((etag = etagFn(chunk, encoding))) {Merge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710
line 175why, one step back175 this.set('ETag', etag);4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 176–182why, one step back176 }177 }178179 // freshness180 if (req.fresh) this.statusCode = 304;181182 // strip irrelevant headersMerge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
line 183why, one step back183 if (204 === this.statusCode || 304 === this.statusCode) {4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 184–189why, one step back184 this.removeHeader('Content-Type');185 this.removeHeader('Content-Length');186 this.removeHeader('Transfer-Encoding');187 chunk = '';188 }189Merge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710
line 190why, one step back190 if (req.method === 'HEAD') {Merge tag '4.11.1'Douglas Christopher Wilsonbefore adoption8a5ecd3
line 191why, one step back191 // skip body for HEAD4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
line 192why, one step back192 this.end();Merge tag '4.11.1'Douglas Christopher Wilsonbefore adoption8a5ecd3
lines 193–195why, one step back193 } else {194 // respond195 this.end(chunk, encoding);4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 196–208why, one step back196 }197198 return this;199};200201/**202 * Send JSON response.203 *204 * Examples:205 *206 * res.json(null);207 * res.json({ user: 'tj' });208 *Deprecate combined status, response signaturesDouglas Christopher Wilsonbefore adoptionfd3b405
line 209why, one step back209 * @param {string|number|boolean|object} objMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 210why, one step back210 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 211–215why, one step back211 */212213res.json = function json(obj) {214 // settings215 var app = this.app;Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
line 216why, one step back216 var escape = app.get('json escape')4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 217–218why, one step back217 var replacer = app.get('json replacer');218 var spaces = app.get('json spaces');Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
line 219why, one step back219 var body = stringify(obj, replacer, spaces, escape)4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 220–236why, one step back220221 // content-type222 if (!this.get('Content-Type')) {223 this.set('Content-Type', 'application/json');224 }225226 return this.send(body);227};228229/**230 * Send JSON response with JSONP callback support.231 *232 * Examples:233 *234 * res.jsonp(null);235 * res.jsonp({ user: 'tj' });236 *Deprecate combined status, response signaturesDouglas Christopher Wilsonbefore adoptionfd3b405
line 237why, one step back237 * @param {string|number|boolean|object} objMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 238why, one step back238 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 239–243why, one step back239 */240241res.jsonp = function jsonp(obj) {242 // settings243 var app = this.app;Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
line 244why, one step back244 var escape = app.get('json escape')4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 245–246why, one step back245 var replacer = app.get('json replacer');246 var spaces = app.get('json spaces');Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
line 247why, one step back247 var body = stringify(obj, replacer, spaces, escape)4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 248–279why, one step back248 var callback = this.req.query[app.get('jsonp callback name')];249250 // content-type251 if (!this.get('Content-Type')) {252 this.set('X-Content-Type-Options', 'nosniff');253 this.set('Content-Type', 'application/json');254 }255256 // fixup callback257 if (Array.isArray(callback)) {258 callback = callback[0];259 }260261 // jsonp262 if (typeof callback === 'string' && callback.length !== 0) {263 this.set('X-Content-Type-Options', 'nosniff');264 this.set('Content-Type', 'text/javascript');265266 // restrict callback charset267 callback = callback.replace(/[^\[\]\w$.]/g, '');268269 // replace chars not allowed in JavaScript that are in JSON270 body = body271 .replace(/\u2028/g, '\\u2028')272 .replace(/\u2029/g, '\\u2029');273274 // the /**/ is a specific security mitigation for "Rosetta Flash JSONP abuse"275 // the typeof check is just to reduce client error noise276 body = '/**/ typeof ' + callback + ' === \'function\' && ' + callback + '(' + body + ');';277 }278279 return this.send(body);Add res.sendFileDouglas Christopher Wilsonbefore adoption2cb029f
lines 280–282why, one step back280};281282/**Add res.sendStatusSeth Samuelbefore adoption12f92a5
lines 283–293why, one step back283 * Send given HTTP status code.284 *285 * Sets the response status to `statusCode` and the body of the286 * response to the standard description from node's http.STATUS_CODES287 * or the statusCode number if no description.288 *289 * Examples:290 *291 * res.sendStatus(200);292 *293 * @param {number} statusCodeMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 294why, one step back294 * @publicAdd res.sendStatusSeth Samuelbefore adoption12f92a5
lines 295–297why, one step back295 */296297res.sendStatus = function sendStatus(statusCode) {Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
line 298why, one step back298 var body = statuses[statusCode] || String(statusCode)Add res.sendStatusSeth Samuelbefore adoption12f92a5
lines 299–306why, one step back299300 this.statusCode = statusCode;301 this.type('txt');302303 return this.send(body);304};305306/**Add res.sendFileDouglas Christopher Wilsonbefore adoption2cb029f
lines 307–309why, one step back307 * Transfer the file at the given `path`.308 *309 * Automatically sets the _Content-Type_ response header field.Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 310why, one step back310 * The callback `callback(err)` is invoked when the transfer is completeAdd res.sendFileDouglas Christopher Wilsonbefore adoption2cb029f
lines 311–343why, one step back311 * or when an error occurs. Be sure to check `res.sentHeader`312 * if you wish to attempt responding, as the header and some data313 * may have already been transferred.314 *315 * Options:316 *317 * - `maxAge` defaulting to 0 (can be string converted by `ms`)318 * - `root` root directory for relative filenames319 * - `headers` object of headers to serve with file320 * - `dotfiles` serve dotfiles, defaulting to false; can be `"allow"` to send them321 *322 * Other options are passed along to `send`.323 *324 * Examples:325 *326 * The following example illustrates how `res.sendFile()` may327 * be used as an alternative for the `static()` middleware for328 * dynamic situations. The code backing `res.sendFile()` is actually329 * the same code, so HTTP cache support etc is identical.330 *331 * app.get('/user/:uid/photos/:file', function(req, res){332 * var uid = req.params.uid333 * , file = req.params.file;334 *335 * req.user.mayViewFilesFrom(uid, function(yes){336 * if (yes) {337 * res.sendFile('/uploads/' + uid + '/' + file);338 * } else {339 * res.send(403, 'Sorry! you cant see that.');340 * }341 * });342 * });343 *Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 344why, one step back344 * @publicAdd res.sendFileDouglas Christopher Wilsonbefore adoption2cb029f
lines 345–346why, one step back345 */346Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 347–348why, one step back347res.sendFile = function sendFile(path, options, callback) {348 var done = callback;Add res.sendFileDouglas Christopher Wilsonbefore adoption2cb029f
line 349why, one step back349 var req = this.req;Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 350why, one step back350 var res = this;Add res.sendFileDouglas Christopher Wilsonbefore adoption2cb029f
line 351why, one step back351 var next = req.next;Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 352why, one step back352 var opts = options || {};Add res.sendFileDouglas Christopher Wilsonbefore adoption2cb029f
lines 353–359why, one step back353354 if (!path) {355 throw new TypeError('path argument is required to res.sendFile');356 }357358 // support function as second arg359 if (typeof options === 'function') {Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 360–361why, one step back360 done = options;361 opts = {};Add res.sendFileDouglas Christopher Wilsonbefore adoption2cb029f
lines 362–363why, one step back362 }363Use path-is-absolute module for absolute path detectionJeremiah Senkpielbefore adoption694869d
line 364why, one step back364 if (!opts.root && !pathIsAbsolute(path)) {Add res.sendFileDouglas Christopher Wilsonbefore adoption2cb029f
lines 365–367why, one step back365 throw new TypeError('path must be absolute or specify root to res.sendFile');366 }367Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 368why, one step back368 // create file streamAdd res.sendFileDouglas Christopher Wilsonbefore adoption2cb029f
line 369why, one step back369 var pathname = encodeURI(path);Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 370why, one step back370 var file = send(req, pathname, opts);Add res.sendFileDouglas Christopher Wilsonbefore adoption2cb029f
line 371why, one step back371Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 372why, one step back372 // transferMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 373–374why, one step back373 sendfile(res, file, opts, function (err) {374 if (done) return done(err);Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 375why, one step back375 if (err && err.code === 'EISDIR') return next();Add res.sendFileDouglas Christopher Wilsonbefore adoption2cb029f
line 376why, one step back376Merge tag '4.11.1'Douglas Christopher Wilsonbefore adoption8a5ecd3
line 377why, one step back377 // next() all but write errorsMerge tag '4.12.4'Douglas Christopher Wilsonbefore adoptionf90e045
line 378why, one step back378 if (err && err.code !== 'ECONNABORTED' && err.syscall !== 'write') {Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 379–381why, one step back379 next(err);380 }381 });4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 382–387why, one step back382};383384/**385 * Transfer the file at the given `path` as an attachment.386 *387 * Optionally providing an alternate attachment `filename`,Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 388why, one step back388 * and optional callback `callback(err)`. The callback is invoked4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 389–391why, one step back389 * when the data transfer is complete, or when an error has390 * ocurred. Be sure to check `res.headersSent` if you plan to respond.391 *Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
lines 392–396why, one step back392 * Optionally providing an `options` object to use with `res.sendFile()`.393 * This function will set the `Content-Disposition` header, overriding394 * any `Content-Disposition` header passed as header options in order395 * to set the attachment and filename.396 *Remove res.sendfileDouglas Christopher Wilsonbefore adoption0fc4f07
line 397why, one step back397 * This method uses `res.sendFile()`.4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
line 398why, one step back398 *Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 399why, one step back399 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 400–401why, one step back400 */401Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
line 402why, one step back402res.download = function download (path, filename, options, callback) {Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 403–404why, one step back403 var done = callback;404 var name = filename;Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
line 405why, one step back405 var opts = options || nullMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 406why, one step back406Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
line 407why, one step back407 // support function as second or third argFix incorrect deprecation warnings on res.downloadDouglas Christopher Wilsonbefore adoption1150ca7
line 408why, one step back408 if (typeof filename === 'function') {Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 409–410why, one step back409 done = filename;410 name = null;Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
lines 411–414why, one step back411 opts = null412 } else if (typeof options === 'function') {413 done = options414 opts = null4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 415–418why, one step back415 }416417 // set Content-Disposition when file is sent418 var headers = {Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 419why, one step back419 'Content-Disposition': contentDisposition(name || path)4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 420–421why, one step back420 };421Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
lines 422–436why, one step back422 // merge user-provided headers423 if (opts && opts.headers) {424 var keys = Object.keys(opts.headers)425 for (var i = 0; i < keys.length; i++) {426 var key = keys[i]427 if (key.toLowerCase() !== 'content-disposition') {428 headers[key] = opts.headers[key]429 }430 }431 }432433 // merge user-provided options434 opts = Object.create(opts)435 opts.headers = headers436Fix incorrect deprecation warnings on res.downloadDouglas Christopher Wilsonbefore adoption1150ca7
lines 437–439why, one step back437 // Resolve the full path for sendFile438 var fullPath = resolve(path);439Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
lines 440–441why, one step back440 // send file441 return this.sendFile(fullPath, opts, done)4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 442–457why, one step back442};443444/**445 * Set _Content-Type_ response header with `type` through `mime.lookup()`446 * when it does not contain "/", or set the Content-Type to `type` otherwise.447 *448 * Examples:449 *450 * res.type('.html');451 * res.type('html');452 * res.type('json');453 * res.type('application/json');454 * res.type('png');455 *456 * @param {String} type457 * @return {ServerResponse} for chainingMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 458why, one step back458 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 459–461why, one step back459 */460461res.contentType =Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 462–467why, one step back462res.type = function contentType(type) {463 var ct = type.indexOf('/') === -1464 ? mime.lookup(type)465 : type;466467 return this.set('Content-Type', ct);4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 468–523why, one step back468};469470/**471 * Respond to the Acceptable formats using an `obj`472 * of mime-type callbacks.473 *474 * This method uses `req.accepted`, an array of475 * acceptable types ordered by their quality values.476 * When "Accept" is not present the _first_ callback477 * is invoked, otherwise the first match is used. When478 * no match is performed the server responds with479 * 406 "Not Acceptable".480 *481 * Content-Type is set for you, however if you choose482 * you may alter this within the callback using `res.type()`483 * or `res.set('Content-Type', ...)`.484 *485 * res.format({486 * 'text/plain': function(){487 * res.send('hey');488 * },489 *490 * 'text/html': function(){491 * res.send('<p>hey</p>');492 * },493 *494 * 'appliation/json': function(){495 * res.send({ message: 'hey' });496 * }497 * });498 *499 * In addition to canonicalized MIME types you may500 * also use extnames mapped to these types:501 *502 * res.format({503 * text: function(){504 * res.send('hey');505 * },506 *507 * html: function(){508 * res.send('<p>hey</p>');509 * },510 *511 * json: function(){512 * res.send({ message: 'hey' });513 * }514 * });515 *516 * By default Express passes an `Error`517 * with a `.status` of 406 to `next(err)`518 * if a match is not made. If you provide519 * a `.default` callback it will be invoked520 * instead.521 *522 * @param {Object} obj523 * @return {ServerResponse} for chainingMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 524why, one step back524 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 525–534why, one step back525 */526527res.format = function(obj){528 var req = this.req;529 var next = req.next;530531 var fn = obj.default;532 if (fn) delete obj.default;533 var keys = Object.keys(obj);534Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 535–537why, one step back535 var key = keys.length > 0536 ? req.accepts(keys)537 : false;4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 538–547why, one step back538539 this.vary("Accept");540541 if (key) {542 this.set('Content-Type', normalizeType(key).value);543 obj[key](req, this, next);544 } else if (fn) {545 fn();546 } else {547 var err = new Error('Not Acceptable');Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 548why, one step back548 err.status = err.statusCode = 406;4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 549–560why, one step back549 err.types = normalizeTypes(keys).map(function(o){ return o.value });550 next(err);551 }552553 return this;554};555556/**557 * Set _Content-Disposition_ header to _attachment_ with optional `filename`.558 *559 * @param {String} filename560 * @return {ServerResponse}Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 561why, one step back561 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 562–563why, one step back562 */563Use content-disposition moduleDouglas Christopher Wilsonbefore adoption6f31218
lines 564–568why, one step back564res.attachment = function attachment(filename) {565 if (filename) {566 this.type(extname(filename));567 }5684.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
line 569why, one step back569 this.set('Content-Disposition', contentDisposition(filename));Use content-disposition moduleDouglas Christopher Wilsonbefore adoption6f31218
line 570why, one step back5704.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 571–574why, one step back571 return this;572};573574/**Merge tag '4.11.1'Douglas Christopher Wilsonbefore adoption8a5ecd3
lines 575–585why, one step back575 * Append additional header `field` with value `val`.576 *577 * Example:578 *579 * res.append('Link', ['<http://localhost/>', '<http://localhost:3000/>']);580 * res.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly');581 * res.append('Warning', '199 Miscellaneous warning');582 *583 * @param {String} field584 * @param {String|Array} val585 * @return {ServerResponse} for chainingMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 586why, one step back586 * @publicMerge tag '4.11.1'Douglas Christopher Wilsonbefore adoption8a5ecd3
lines 587–603why, one step back587 */588589res.append = function append(field, val) {590 var prev = this.get(field);591 var value = val;592593 if (prev) {594 // concat the new and prev vals595 value = Array.isArray(prev) ? prev.concat(val)596 : Array.isArray(val) ? [prev].concat(val)597 : [prev, val];598 }599600 return this.set(field, value);601};602603/**4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 604–614why, one step back604 * Set header `field` to `val`, or pass605 * an object of header fields.606 *607 * Examples:608 *609 * res.set('Foo', ['bar', 'baz']);610 * res.set('Accept', 'application/json');611 * res.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' });612 *613 * Aliased as `res.header()`.614 *Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 615–616why, one step back615 * @param {String|Object} field616 * @param {String|Array} val4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
line 617why, one step back617 * @return {ServerResponse} for chainingMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 618why, one step back618 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 619–623why, one step back619 */620621res.set =622res.header = function header(field, val) {623 if (arguments.length === 2) {Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 624–628why, one step back624 var value = Array.isArray(val)625 ? val.map(String)626 : String(val);627628 // add charset to content-typeMerge tag '4.15.4'Douglas Christopher Wilsonbefore adoptionc319fe2
lines 629–636why, one step back629 if (field.toLowerCase() === 'content-type') {630 if (Array.isArray(value)) {631 throw new TypeError('Content-Type cannot be set to an Array');632 }633 if (!charsetRegExp.test(value)) {634 var charset = mime.charsets.lookup(value.split(';')[0]);635 if (charset) value += '; charset=' + charset.toLowerCase();636 }4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
line 637why, one step back637 }Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 638–639why, one step back638639 this.setHeader(field, value);4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 640–652why, one step back640 } else {641 for (var key in field) {642 this.set(key, field[key]);643 }644 }645 return this;646};647648/**649 * Get value for header `field`.650 *651 * @param {String} field652 * @return {String}Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 653why, one step back653 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 654–663why, one step back654 */655656res.get = function(field){657 return this.getHeader(field);658};659660/**661 * Clear cookie `name`.662 *663 * @param {String} nameMerge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
line 664why, one step back664 * @param {Object} [options]build: fix up jsdoc return valuesVasilyev Dmitrybefore adoptionfd86ab8
line 665why, one step back665 * @return {ServerResponse} for chainingMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 666why, one step back666 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 667–668why, one step back667 */668Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 669–672why, one step back669res.clearCookie = function clearCookie(name, options) {670 var opts = merge({ expires: new Date(1), path: '/' }, options);671672 return this.cookie(name, '', opts);4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 673–675why, one step back673};674675/**Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 676why, one step back676 * Set cookie `name` to `value`, with the given `options`.4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 677–692why, one step back677 *678 * Options:679 *680 * - `maxAge` max-age in milliseconds, converted to `expires`681 * - `signed` sign the cookie682 * - `path` defaults to "/"683 *684 * Examples:685 *686 * // "Remember Me" for 15 minutes687 * res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true });688 *689 * // save as above690 * res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true })691 *692 * @param {String} nameMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 693why, one step back693 * @param {String|Object} valueMerge tag '4.15.4'Douglas Christopher Wilsonbefore adoptionc319fe2
line 694why, one step back694 * @param {Object} [options]build: fix up jsdoc return valuesVasilyev Dmitrybefore adoptionfd86ab8
line 695why, one step back695 * @return {ServerResponse} for chainingMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 696why, one step back696 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 697–698why, one step back697 */698Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 699–700why, one step back699res.cookie = function (name, value, options) {700 var opts = merge({}, options);4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
line 701why, one step back701 var secret = this.req.secret;Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 702–705why, one step back702 var signed = opts.signed;703704 if (signed && !secret) {705 throw new Error('cookieParser("secret") required for signed cookies');4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 706–707why, one step back706 }707Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 708–713why, one step back708 var val = typeof value === 'object'709 ? 'j:' + JSON.stringify(value)710 : String(value);711712 if (signed) {713 val = 's:' + sign(val, secret);4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
line 714why, one step back714 }Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 715–726why, one step back715716 if ('maxAge' in opts) {717 opts.expires = new Date(Date.now() + opts.maxAge);718 opts.maxAge /= 1000;719 }720721 if (opts.path == null) {722 opts.path = '/';723 }724725 this.append('Set-Cookie', cookie.serialize(name, String(val), opts));7264.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 727–742why, one step back727 return this;728};729730/**731 * Set the location header to `url`.732 *733 * The given `url` can also be "back", which redirects734 * to the _Referrer_ or _Referer_ headers or "/".735 *736 * Examples:737 *738 * res.location('/foo/bar').;739 * res.location('http://example.com');740 * res.location('../login');741 *742 * @param {String} urlbuild: fix up jsdoc return valuesVasilyev Dmitrybefore adoptionfd86ab8
line 743why, one step back743 * @return {ServerResponse} for chainingMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 744why, one step back744 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 745–746why, one step back745 */746Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 747–748why, one step back747res.location = function location(url) {748 var loc = url;4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 749–750why, one step back749750 // "back" is an alias for the referrerMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 751–753why, one step back751 if (url === 'back') {752 loc = this.req.get('Referrer') || '/';753 }4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
line 754why, one step back754Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 755why, one step back755 // set locationMerge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
line 756why, one step back756 return this.set('Location', encodeUrl(loc));4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 757–773why, one step back757};758759/**760 * Redirect to the given `url` with optional response `status`761 * defaulting to 302.762 *763 * The resulting `url` is determined by `res.location()`, so764 * it will play nicely with mounted apps, relative paths,765 * `"back"` etc.766 *767 * Examples:768 *769 * res.redirect('/foo/bar');770 * res.redirect('http://example.com');771 * res.redirect(301, 'http://example.com');772 * res.redirect('../login'); // /blog/post/1 -> /blog/login773 *Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 774why, one step back774 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 775–783why, one step back775 */776777res.redirect = function redirect(url) {778 var address = url;779 var body;780 var status = 302;781782 // allow status / url783 if (arguments.length === 2) {Remove res.redirect(url, status) signatureMike Tunnicliffebefore adoption71395f5
lines 784–785why, one step back784 status = arguments[0]785 address = arguments[1]4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 786–788why, one step back786 }787788 // Set location headerMerge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
line 789why, one step back789 address = this.location(address).get('Location');4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 790–793why, one step back790791 // Support text/{plain,html} by default792 this.format({793 text: function(){Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
line 794why, one step back794 body = statuses[status] + '. Redirecting to ' + address4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 795–797why, one step back795 },796797 html: function(){Fix res.redirect body when redirect status specifiedAlex Upadhyaybefore adoption6f0302f
line 798why, one step back798 var u = escapeHtml(address);Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
line 799why, one step back799 body = '<p>' + statuses[status] + '. Redirecting to <a href="' + u + '">' + u + '</a></p>'4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 800–812why, one step back800 },801802 default: function(){803 body = '';804 }805 });806807 // Respond808 this.statusCode = status;809 this.set('Content-Length', Buffer.byteLength(body));810811 if (this.req.method === 'HEAD') {812 this.end();Merge tag '4.11.2'Douglas Christopher Wilsonbefore adoptiona9ef9e1
lines 813–814why, one step back813 } else {814 this.end(body);4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 815–822why, one step back815 }816};817818/**819 * Add `field` to Vary. If already present in the Vary set, then820 * this call is simply ignored.821 *822 * @param {Array|String} fieldbuild: fix up jsdoc return valuesVasilyev Dmitrybefore adoptionfd86ab8
line 823why, one step back823 * @return {ServerResponse} for chainingMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 824why, one step back824 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 825–842why, one step back825 */826827res.vary = function(field){828 vary(this, field);829830 return this;831};832833/**834 * Render `view` with the given `options` and optional callback `fn`.835 * When a callback function is given a response will _not_ be made836 * automatically, otherwise a response of _200_ and _text/html_ is given.837 *838 * Options:839 *840 * - `cache` boolean hinting to the engine it should cache841 * - `filename` filename of the view being rendered842 *Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 843why, one step back843 * @public4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 844–845why, one step back844 */845Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 846–849why, one step back846res.render = function render(view, options, callback) {847 var app = this.req.app;848 var done = callback;849 var opts = options || {};4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
line 850why, one step back850 var req = this.req;Merge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 851why, one step back851 var self = this;4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 852–853why, one step back852853 // support callback function as second argMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
lines 854–856why, one step back854 if (typeof options === 'function') {855 done = options;856 opts = {};4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 857–859why, one step back857 }858859 // merge res.localsMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 860why, one step back860 opts._locals = self.locals;4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 861–862why, one step back861862 // default callback to respondMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 863why, one step back863 done = done || function (err, str) {4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
lines 864–868why, one step back864 if (err) return req.next(err);865 self.send(str);866 };867868 // renderMerge tag '4.13.1'Douglas Christopher Wilsonbefore adoptionb309b87
line 869why, one step back869 app.render(view, opts, done);4.6.0Douglas Christopher Wilsonbefore adoption8ba3f39
line 870why, one step back870};Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 871–874why, one step back871872// pipe the send file stream873function sendfile(res, file, options, callback) {874 var done = false;Merge tag '4.11.1'Douglas Christopher Wilsonbefore adoption8a5ecd3
line 875why, one step back875 var streaming;Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 876why, one step back876Merge tag '4.11.1'Douglas Christopher Wilsonbefore adoption8a5ecd3
lines 877–882why, one step back877 // request aborted878 function onaborted() {879 if (done) return;880 done = true;881882 var err = new Error('Request aborted');Merge tag '4.12.4'Douglas Christopher Wilsonbefore adoptionf90e045
line 883why, one step back883 err.code = 'ECONNABORTED';Merge tag '4.11.1'Douglas Christopher Wilsonbefore adoption8a5ecd3
lines 884–886why, one step back884 callback(err);885 }886Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 887–910why, one step back887 // directory888 function ondirectory() {889 if (done) return;890 done = true;891892 var err = new Error('EISDIR, read');893 err.code = 'EISDIR';894 callback(err);895 }896897 // errors898 function onerror(err) {899 if (done) return;900 done = true;901 callback(err);902 }903904 // ended905 function onend() {906 if (done) return;907 done = true;908 callback();909 }910Merge tag '4.11.1'Douglas Christopher Wilsonbefore adoption8a5ecd3
lines 911–915why, one step back911 // file912 function onfile() {913 streaming = false;914 }915Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 916–917why, one step back916 // finished917 function onfinish(err) {Merge tag '4.12.4'Douglas Christopher Wilsonbefore adoptionf90e045
line 918why, one step back918 if (err && err.code === 'ECONNRESET') return onaborted();Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 919–922why, one step back919 if (err) return onerror(err);920 if (done) return;921922 setImmediate(function () {Merge tag '4.11.1'Douglas Christopher Wilsonbefore adoption8a5ecd3
lines 923–927why, one step back923 if (streaming !== false && !done) {924 onaborted();925 return;926 }927Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 928–929why, one step back928 if (done) return;929 done = true;Merge tag '4.11.1'Douglas Christopher Wilsonbefore adoption8a5ecd3
line 930why, one step back930 callback();Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 931–933why, one step back931 });932 }933Merge tag '4.11.1'Douglas Christopher Wilsonbefore adoption8a5ecd3
lines 934–939why, one step back934 // streaming935 function onstream() {936 streaming = true;937 }938939 file.on('directory', ondirectory);Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 940–941why, one step back940 file.on('end', onend);941 file.on('error', onerror);Merge tag '4.11.1'Douglas Christopher Wilsonbefore adoption8a5ecd3
lines 942–943why, one step back942 file.on('file', onfile);943 file.on('stream', onstream);Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 944–960why, one step back944 onFinished(res, onfinish);945946 if (options.headers) {947 // set headers on successful transfer948 file.on('headers', function headers(res) {949 var obj = options.headers;950 var keys = Object.keys(obj);951952 for (var i = 0; i < keys.length; i++) {953 var k = keys[i];954 res.setHeader(k, obj[k]);955 }956 });957 }958959 // pipe960 file.pipe(res);Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
lines 961–963why, one step back961}962963/**Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
lines 964–971why, one step back964 * Stringify JSON, like JSON.stringify, but v8 optimized, with the965 * ability to escape characters that can trigger HTML sniffing.966 *967 * @param {*} value968 * @param {function} replaces969 * @param {number} spaces970 * @param {boolean} escape971 * @returns {string}Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
lines 972–974why, one step back972 * @private973 */974Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
line 975why, one step back975function stringify (value, replacer, spaces, escape) {Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
lines 976–977why, one step back976 // v8 checks arguments.length for optimizing simple call977 // https://bugs.chromium.org/p/v8/issues/detail?id=4730Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
line 978why, one step back978 var json = replacer || spacesMerge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6
lines 979–980why, one step back979 ? JSON.stringify(value, replacer, spaces)980 : JSON.stringify(value);Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
lines 981–997why, one step back981982 if (escape) {983 json = json.replace(/[<>&]/g, function (c) {984 switch (c.charCodeAt(0)) {985 case 0x3c:986 return '\\u003c'987 case 0x3e:988 return '\\u003e'989 case 0x26:990 return '\\u0026'991 default:992 return c993 }994 })995 }996997 return jsonInvoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 998why, one step back998}