Skip to content
Myr

Server#respond() is now the only way to commit a response body

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

authored by visionmedia · committed by visionmedia · parent 8cac1eb · Browse files · 1 file+6 added−5 removed
This commit

State

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

Diff stats

1 file+6 added−5 removed

  • other:+6 added−5 removed

1 file+6 added−5 removed

modified:lib/express/core.js+6 added-5 removed
233 unmodified lines
234 * @api private235 */236 237 route: function(request, response){238 var body 239 response.headers = {}240 this.request = request, this.response = response241 this.request.uri.path = normalizePath(this.request.uri.path)241 if (typeof (this.response.body = Express.router.route(request)) == 'string')242 this.respond()242 if (typeof (body = Express.router.route(request)) == 'string')243 halt(200, body)244 },245 246 /**247 * Respond immediately with optional _body_.
2 unmodified lines
250 * @api private251 */252 253 respond: function(body){253 if (body) this.response.body = body254 if (typeof this.response.body != 'string') throw new InvalidResponseBody(this.request)254 if (typeof body != 'string') throw new InvalidResponseBody(this.request)255 if (typeof this.response.status != 'number') throw new InvalidStatusCode(this.response.status)256 this.response.sendHeader(this.response.status, this.response.headers)256 this.response.sendBody(this.response.body)257 this.response.sendBody(body)258 this.response.finish()259 }260})261
10 unmodified lines