Skip to content
Myr

response.js

This file

Path

lib/response.js

480 lines · 11.2 KiB · JavaScript

Last changed by

Added support for `res.set(obj)`. Closes #834Tj Holowaychukbefore adoption021655a

History of this file

Take it

The walk stopped after 200 commits: lines older than 723774a point at it.

added quick start to guideTj Holowaychukbefore adoption723774a

lines 1–16why, one step back
1
2/*!3 * Express - response4 * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>5 * MIT Licensed6 */78/**9 * Module dependencies.10 */1112var fs = require('fs')13 , http = require('http')14 , path = require('path')15 , connect = require('connect')16 , utils = connect.utils

refactored `res.redirect()` slightlyTj Holowaychukbefore adoption6bd5182

line 17why, one step back
17 , statusCodes = http.STATUS_CODES

added quick start to guideTj Holowaychukbefore adoption723774a

lines 18–25why, one step back
18 , parseRange = require('./utils').parseRange
19 , res = http.ServerResponse.prototype20 , send = connect.static.send21 , mime = require('mime')22 , basename = path.basename23 , join = path.join;2425/**

Changed `res.{send,json}()` status code to the first arg at all timesTj Holowaychukbefore adoptionc35cd7f

line 26why, one step back
26 * Send a response.

added quick start to guideTj Holowaychukbefore adoption723774a

lines 27–32why, one step back
27 *
28 * Examples:29 *30 * res.send(new Buffer('wahoo'));31 * res.send({ some: 'json' });32 * res.send('<p>some html</p>');

Changed `res.{send,json}()` status code to the first arg at all timesTj Holowaychukbefore adoptionc35cd7f

line 33why, one step back
33 * res.send(404, 'Sorry, cant find that');

added quick start to guideTj Holowaychukbefore adoption723774a

lines 34–35why, one step back
34 * res.send(404);
35 *

Changed `res.{send,json}()` status code to the first arg at all timesTj Holowaychukbefore adoptionc35cd7f

lines 36–37why, one step back
36 * @param {Mixed} body or status
37 * @param {Mixed} body

added quick start to guideTj Holowaychukbefore adoption723774a

lines 38–41why, one step back
38 * @return {ServerResponse}
39 * @api public40 */41

Changed `res.{send,json}()` status code to the first arg at all timesTj Holowaychukbefore adoptionc35cd7f

line 42why, one step back
42res.send = function(body){

refactored `res.send()`Tj Holowaychukbefore adoption2c734e2

lines 43–45why, one step back
43 var req = this.req
44 , head = 'HEAD' == req.method;45

Changed `res.{send,json}()` status code to the first arg at all timesTj Holowaychukbefore adoptionc35cd7f

lines 46–50why, one step back
46 // allow status / body
47 if (2 == arguments.length) {48 this.statusCode = body;49 body = arguments[1];50 }

added quick start to guideTj Holowaychukbefore adoption723774a

lines 51–52why, one step back
51
52 switch (typeof body) {

Changed `res.{send,json}()` status code to the first arg at all timesTj Holowaychukbefore adoptionc35cd7f

line 53why, one step back
53 // response status

added quick start to guideTj Holowaychukbefore adoption723774a

line 54why, one step back
54 case 'number':

Changed `res.{send,json}()` status code to the first arg at all timesTj Holowaychukbefore adoptionc35cd7f

lines 55–57why, one step back
55 this.header('Content-Type') || this.contentType('.txt');
56 this.statusCode = body;57 body = http.STATUS_CODES[body];

added quick start to guideTj Holowaychukbefore adoption723774a

line 58why, one step back
58 break;

Changed `res.{send,json}()` status code to the first arg at all timesTj Holowaychukbefore adoptionc35cd7f

line 59why, one step back
59 // string defaulting to html

added quick start to guideTj Holowaychukbefore adoption723774a

lines 60–67why, one step back
60 case 'string':
61 if (!this.header('Content-Type')) {62 this.charset = this.charset || 'utf-8';63 this.contentType('.html');64 }65 break;66 case 'boolean':67 case 'object':

Changed `res.send(null)` responds with empty stringTj Holowaychukbefore adoption376bedf

lines 68–70why, one step back
68 if (null == body) {
69 body = '';70 } else if (Buffer.isBuffer(body)) {

Changed `res.{send,json}()` status code to the first arg at all timesTj Holowaychukbefore adoptionc35cd7f

line 71why, one step back
71 this.header('Content-Type') || this.contentType('.bin');

added quick start to guideTj Holowaychukbefore adoption723774a

line 72why, one step back
72 } else {

Changed `res.{send,json}()` status code to the first arg at all timesTj Holowaychukbefore adoptionc35cd7f

line 73why, one step back
73 return this.json(body);

added quick start to guideTj Holowaychukbefore adoption723774a

lines 74–78why, one step back
74 }
75 break;76 }7778 // populate Content-Length

Fixed [23]04 supportTj Holowaychukbefore adoption5ac5352

line 79why, one step back
79 if (undefined !== body && !this.header('Content-Length')) {

added quick start to guideTj Holowaychukbefore adoption723774a

lines 80–85why, one step back
80 this.header('Content-Length', Buffer.isBuffer(body)
81 ? body.length82 : Buffer.byteLength(body));83 }8485 // strip irrelevant headers

Changed `res.{send,json}()` status code to the first arg at all timesTj Holowaychukbefore adoptionc35cd7f

line 86why, one step back
86 if (204 == this.statusCode || 304 == this.statusCode) {

added quick start to guideTj Holowaychukbefore adoption723774a

lines 87–88why, one step back
87 this.removeHeader('Content-Type');
88 this.removeHeader('Content-Length');

Fixed 204 / 304 responsesTj Holowaychukbefore adoptionc631eb4

line 89why, one step back
89 body = '';

added quick start to guideTj Holowaychukbefore adoption723774a

lines 90–92why, one step back
90 }
9192 // respond

refactored `res.send()`Tj Holowaychukbefore adoption2c734e2

line 93why, one step back
93 this.end(head ? null : body);

Merge branch 'feature/res-json'Tj Holowaychukbefore adoption9e4020e

lines 94–97why, one step back
94 return this;
95};9697/**

Changed `res.{send,json}()` status code to the first arg at all timesTj Holowaychukbefore adoptionc35cd7f

line 98why, one step back
98 * Send JSON response.

Merge branch 'feature/res-json'Tj Holowaychukbefore adoption9e4020e

lines 99–103why, one step back
99 *
100 * Examples:101 *102 * res.json(null);103 * res.json({ user: 'tj' });

Changed `res.{send,json}()` status code to the first arg at all timesTj Holowaychukbefore adoptionc35cd7f

lines 104–105why, one step back
104 * res.json(500, 'oh noes!');
105 * res.json(404, 'I dont have that');

Merge branch 'feature/res-json'Tj Holowaychukbefore adoption9e4020e

line 106why, one step back
106 *

Changed `res.{send,json}()` status code to the first arg at all timesTj Holowaychukbefore adoptionc35cd7f

line 107why, one step back
107 * @param {Mixed} obj or status

Merge branch 'feature/res-json'Tj Holowaychukbefore adoption9e4020e

lines 108–112why, one step back
108 * @param {Mixed} obj
109 * @return {ServerResponse}110 * @api public111 */112

Changed `res.{send,json}()` status code to the first arg at all timesTj Holowaychukbefore adoptionc35cd7f

lines 113–119why, one step back
113res.json = function(obj){
114 // allow status / body115 if (2 == arguments.length) {116 this.statusCode = obj;117 obj = arguments[1];118 }119

Added `res.json()` JSONP support. Closes #737Tj Holowaychukbefore adoption73ea5cd

lines 120–123why, one step back
120 var body = JSON.stringify(obj)
121 , callback = this.req.query.callback122 , jsonp = this.app.enabled('jsonp callback');123

Merge branch 'feature/res-json'Tj Holowaychukbefore adoption9e4020e

lines 124–125why, one step back
124 this.charset = this.charset || 'utf-8';
125 this.header('Content-Type', 'application/json');

Added `res.json()` JSONP support. Closes #737Tj Holowaychukbefore adoption73ea5cd

lines 126–128why, one step back
126
127 if (callback && jsonp) {128 this.header('Content-Type', 'text/javascript');

Revert "removed jsonp stripping"Tj Holowaychukbefore adoption60d16ea

line 129why, one step back
129 body = callback.replace(/[^\w$.]/g, '') + '(' + body + ');';

Added `res.json()` JSONP support. Closes #737Tj Holowaychukbefore adoption73ea5cd

lines 130–131why, one step back
130 }
131

Changed `res.{send,json}()` status code to the first arg at all timesTj Holowaychukbefore adoptionc35cd7f

line 132why, one step back
132 return this.send(body);

added quick start to guideTj Holowaychukbefore adoption723774a

lines 133–134why, one step back
133};
134

docs for res.status()Tj Holowaychukbefore adoption9477c9b

lines 135–142why, one step back
135/**
136 * Set status `code`.137 *138 * @param {Number} code139 * @return {ServerResponse}140 * @api public141 */142

Added chainable res.status(code)Tj Holowaychukbefore adoptionb04be51

lines 143–147why, one step back
143res.status = function(code){
144 this.statusCode = code;145 return this;146};147

added quick start to guideTj Holowaychukbefore adoption723774a

line 148why, one step back
148/**

refactored `res.sendfile()`Tj Holowaychukbefore adoption5da28be

lines 149–152why, one step back
149 * Transfer the file at the given `path`.
150 * 151 * Automatically sets the _Content-Type_ response header field.152 * The callback `fn(err)` is invoked when the transfer is complete

make `res.sendfile()` more like `res.download()`. Closes #774Tj Holowaychukbefore adoption7a476fc

line 153why, one step back
153 * or when an error occurs. Be sure to check `res.sentHeader`

refactored `res.sendfile()`Tj Holowaychukbefore adoption5da28be

lines 154–155why, one step back
154 * if you wish to attempt responding, as the header and some data
155 * may have already been transferred.

added quick start to guideTj Holowaychukbefore adoption723774a

lines 156–168why, one step back
156 *
157 * Options:158 *159 * - `maxAge` defaulting to 0160 * - `root` root directory for relative filenames161 *162 * @param {String} path163 * @param {Object|Function} options or fn164 * @param {Function} fn165 * @api public166 */167168res.sendfile = function(path, options, fn){

refactored `res.sendfile()`Tj Holowaychukbefore adoption5da28be

line 169why, one step back
169 var self = this

fixed `res.sendfile()` 404 supportTj Holowaychukbefore adoptiond2df055

line 170why, one step back
170 , req = self.req

refactored `res.sendfile()`Tj Holowaychukbefore adoption5da28be

lines 171–172why, one step back
171 , next = this.req.next
172 , options = options || {};

added quick start to guideTj Holowaychukbefore adoption723774a

lines 173–179why, one step back
173
174 // support function as second arg175 if ('function' == typeof options) {176 fn = options;177 options = {};178 }179

refactored `res.sendfile()`Tj Holowaychukbefore adoption5da28be

lines 180–182why, one step back
180 // callback
181 options.callback = function(err){182 // TODO: remove when node adds this

make `res.sendfile()` more like `res.download()`. Closes #774Tj Holowaychukbefore adoption7a476fc

lines 183–189why, one step back
183 self.sentHeader = !! self._header;
184185 // error186 if (err) {187 // ditch content-disposition to prevent funky responses188 if (!self.sentHeader) self.removeHeader('Content-Disposition');189

fixed `res.sendfile()` 404 supportTj Holowaychukbefore adoptiond2df055

lines 190–192why, one step back
190 // not found
191 if ('ENOENT' == err.code) return req.next();192

make `res.sendfile()` more like `res.download()`. Closes #774Tj Holowaychukbefore adoption7a476fc

lines 193–198why, one step back
193 // lost in limbo if there's no callback
194 if (self.sentHeader) return fn && fn(err);195196 // callback available197 if (fn) return fn(err);198

fixed `res.sendfile()` 404 supportTj Holowaychukbefore adoptiond2df055

line 199why, one step back
199 return req.next(err);

make `res.sendfile()` more like `res.download()`. Closes #774Tj Holowaychukbefore adoption7a476fc

lines 200–202why, one step back
200 }
201202 fn && fn();

refactored `res.sendfile()`Tj Holowaychukbefore adoption5da28be

lines 203–205why, one step back
203 };
204205 // transfer

added quick start to guideTj Holowaychukbefore adoption723774a

lines 206–210why, one step back
206 options.path = encodeURIComponent(path);
207 send(this.req, this, next, options);208};209210/**

build `res.download()` on top of `res.sendfile()`Tj Holowaychukbefore adoptiond3ccdbc

lines 211–234why, one step back
211 * Transfer the file at the given `path` as an attachment.
212 *213 * Optionally providing an alternate attachment `filename`,214 * and optional callback `fn(err)`. The callback is invoked215 * when the data transfer is complete, or when an error has216 * ocurred. Be sure to check `res.sendHeader` if you plan to respond.217 *218 * @param {String} path219 * @param {String|Function} filename or fn220 * @param {Function} fn221 * @api public222 */223224res.download = function(path, filename, fn){225 // support function as second arg226 if ('function' == typeof filename) {227 fn = filename;228 filename = null;229 }230231 return this.attachment(filename || path).sendfile(path, fn);232};233234/**

added quick start to guideTj Holowaychukbefore adoption723774a

lines 235–246why, one step back
235 * Set _Content-Type_ response header passed through `mime.lookup()`.
236 *237 * Examples:238 *239 * var filename = 'path/to/image.png';240 * res.contentType(filename);241 * // res.headers['Content-Type'] is now "image/png"242 *243 * res.contentType('.html');244 * res.contentType('html');245 * res.contentType('json');246 * res.contentType('png');

Added res.type() alias of res.contentType()Tj Holowaychukbefore adoption54c1a20

line 247why, one step back
247 * res.type('png');

added quick start to guideTj Holowaychukbefore adoption723774a

lines 248–249why, one step back
248 *
249 * @param {String} type

docsTj Holowaychukbefore adoptionbb9d505

line 250why, one step back
250 * @return {ServerResponse} for chaining

added quick start to guideTj Holowaychukbefore adoption723774a

lines 251–253why, one step back
251 * @api public
252 */253

Added res.type() alias of res.contentType()Tj Holowaychukbefore adoption54c1a20

lines 254–255why, one step back
254res.contentType =
255res.type = function(type){

added quick start to guideTj Holowaychukbefore adoption723774a

lines 256–275why, one step back
256 return this.header('Content-Type', mime.lookup(type));
257};258259/**260 * Set _Content-Disposition_ header to _attachment_ with optional `filename`.261 *262 * @param {String} filename263 * @return {ServerResponse}264 * @api public265 */266267res.attachment = function(filename){268 if (filename) this.contentType(filename);269 this.header('Content-Disposition', filename270 ? 'attachment; filename="' + basename(filename) + '"'271 : 'attachment');272 return this;273};274275/**

Added support for `res.set(obj)`. Closes #834Tj Holowaychukbefore adoption021655a

lines 276–277why, one step back
276 * Set header `field` to `val`, or pass
277 * an object of of header fields.

Added `res.set(field, val)` as an alternative to `res.header()`Tj Holowaychukbefore adoption19a1a22

line 278why, one step back
278 *

Added support for `res.set(obj)`. Closes #834Tj Holowaychukbefore adoption021655a

lines 279–284why, one step back
279 * Examples:
280 *281 * res.set('Accept', 'application/json');282 * res.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' });283 *284 * @param {String|Object} field

Added `res.set(field, val)` as an alternative to `res.header()`Tj Holowaychukbefore adoption19a1a22

lines 285–289why, one step back
285 * @param {String} val
286 * @return {ServerResponse} for chaining287 * @api public288 */289

Added `res.get(field)` as an alternative to `res.header(field)`Tj Holowaychukbefore adoptionc8c6aa2

line 290why, one step back
290res.set = function(field, val){

Added support for `res.set(obj)`. Closes #834Tj Holowaychukbefore adoption021655a

lines 291–297why, one step back
291 if (2 == arguments.length) {
292 this.setHeader(field, val);293 } else {294 for (var key in field) {295 this.setHeader(key, field[key]);296 }297 }

Added `res.set(field, val)` as an alternative to `res.header()`Tj Holowaychukbefore adoption19a1a22

lines 298–301why, one step back
298 return this;
299};300301/**

Added `res.get(field)` as an alternative to `res.header(field)`Tj Holowaychukbefore adoptionc8c6aa2

line 302why, one step back
302 * Get value for header `field`.

added quick start to guideTj Holowaychukbefore adoption723774a

line 303why, one step back
303 *

Added `res.get(field)` as an alternative to `res.header(field)`Tj Holowaychukbefore adoptionc8c6aa2

lines 304–315why, one step back
304 * @param {String} field
305 * @return {String}306 * @api public307 */308309res.get = function(field){310 return this.getHeader(field);311};312313/**314 * Set or get response header `field` with optional `val`.315 *

added quick start to guideTj Holowaychukbefore adoption723774a

lines 316–317why, one step back
316 * @param {String} name
317 * @param {String} val

Merge branch 'remove-header-fields'Tj Holowaychukbefore adoption772c135

line 318why, one step back
318 * @return {ServerResponse} for chaining

added quick start to guideTj Holowaychukbefore adoption723774a

lines 319–321why, one step back
319 * @api public
320 */321

Added `res.get(field)` as an alternative to `res.header(field)`Tj Holowaychukbefore adoptionc8c6aa2

lines 322–324why, one step back
322res.header = function(field, val){
323 if (1 == arguments.length) return this.getHeader(field);324 this.setHeader(field, val);

Refactored `res.header()`Tj Holowaychukbefore adoption54d3751

line 325why, one step back
325 return this;

added quick start to guideTj Holowaychukbefore adoption723774a

lines 326–332why, one step back
326};
327328/**329 * Clear cookie `name`.330 *331 * @param {String} name332 * @param {Object} options

Changed `res.{cookie,clearCookie}()` return resTj Holowaychukbefore adoptiona3cddb8

line 333why, one step back
333 * @param {ServerResponse} for chaining

added quick start to guideTj Holowaychukbefore adoption723774a

lines 334–338why, one step back
334 * @api public
335 */336337res.clearCookie = function(name, options){338 var opts = { expires: new Date(1) };

Changed `res.{cookie,clearCookie}()` return resTj Holowaychukbefore adoptiona3cddb8

line 339why, one step back
339 return this.cookie(name, '', options

added quick start to guideTj Holowaychukbefore adoption723774a

lines 340–349why, one step back
340 ? utils.merge(options, opts)
341 : opts);342};343344/**345 * Set cookie `name` to `val`, with the given `options`.346 *347 * Options:348 *349 * - `maxAge` max-age in milliseconds, converted to `expires`

Merged basepath setting. Closes #813Tj Holowaychukbefore adoptione9abe1b

line 350why, one step back
350 * - `path` defaults to the "basepath" setting which is typically "/"

added quick start to guideTj Holowaychukbefore adoption723774a

lines 351–368why, one step back
351 *
352 * Examples:353 *354 * // "Remember Me" for 15 minutes355 * res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true });356 *357 * // save as above358 * res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true })359 *360 * @param {String} name361 * @param {String} val362 * @param {Options} options363 * @api public364 */365366res.cookie = function(name, val, options){367 options = options || {};368 if ('maxAge' in options) options.expires = new Date(Date.now() + options.maxAge);

Merged basepath setting. Closes #813Tj Holowaychukbefore adoptione9abe1b

line 369why, one step back
369 if (undefined === options.path) options.path = this.app.set('basepath');

added quick start to guideTj Holowaychukbefore adoption723774a

lines 370–371why, one step back
370 var cookie = utils.serializeCookie(name, val, options);
371 this.header('Set-Cookie', cookie);

Changed `res.{cookie,clearCookie}()` return resTj Holowaychukbefore adoptiona3cddb8

line 372why, one step back
372 return this;

added quick start to guideTj Holowaychukbefore adoption723774a

lines 373–376why, one step back
373};
374375/**376 * Redirect to the given `url` with optional response `status`

Changed `res.redirect()` signature to accept status first. Closes #832Tj Holowaychukbefore adoptione301d43

line 377why, one step back
377 * defaulting to 302.

added quick start to guideTj Holowaychukbefore adoption723774a

lines 378–381why, one step back
378 *
379 * The given `url` can also be the name of a mapped url, for380 * example by default express supports "back" which redirects381 * to the _Referrer_ or _Referer_ headers or the application's

Merged basepath setting. Closes #813Tj Holowaychukbefore adoptione9abe1b

lines 382–383why, one step back
382 * "basepath" setting. Express also supports "basepath" out of the box,
383 * which can be set via `app.set('basepath', '/blog');`.

added quick start to guideTj Holowaychukbefore adoption723774a

line 384why, one step back
384 *

Changed `res.redirect()` signature to accept status first. Closes #832Tj Holowaychukbefore adoptione301d43

lines 385–390why, one step back
385 * Examples:
386 *387 * res.redirect('/foo/bar');388 * res.redirect('http://example.com');389 * res.redirect(301, 'http://example.com');390 *

added quick start to guideTj Holowaychukbefore adoption723774a

lines 391–424why, one step back
391 * Redirect Mapping:
392 * 393 * To extend the redirect mapping capabilities that Express provides,394 * we may use the `app.redirect()` method:395 * 396 * app.redirect('google', 'http://google.com');397 * 398 * Now in a route we may call:399 *400 * res.redirect('google');401 *402 * We may also map dynamic redirects:403 *404 * app.redirect('comments', function(req, res){405 * return '/post/' + req.params.id + '/comments';406 * });407 *408 * So now we may do the following, and the redirect will dynamically adjust to409 * the context of the request. If we called this route with _GET /post/12_ our410 * redirect _Location_ would be _/post/12/comments_.411 *412 * app.get('/post/:id', function(req, res){413 * res.redirect('comments');414 * });415 *416 * Unless an absolute `url` is given, the app's mount-point417 * will be respected. For example if we redirect to `/posts`,418 * and our app is mounted at `/blog` we will redirect to `/blog/posts`.419 *420 * @param {String} url421 * @param {Number} code422 * @api public423 */424

Changed `res.redirect()` signature to accept status first. Closes #832Tj Holowaychukbefore adoptione301d43

line 425why, one step back
425res.redirect = function(url){

added quick start to guideTj Holowaychukbefore adoption723774a

lines 426–427why, one step back
426 var app = this.app
427 , req = this.req

Merged basepath setting. Closes #813Tj Holowaychukbefore adoptione9abe1b

line 428why, one step back
428 , base = app.set('basepath') || app.route

Fixed `res.redirect()` HEAD supportTj Holowaychukbefore adoptiond3937b9

line 429why, one step back
429 , head = 'HEAD' == req.method

Changed `res.redirect()` signature to accept status first. Closes #832Tj Holowaychukbefore adoptione301d43

line 430why, one step back
430 , status = 302

added quick start to guideTj Holowaychukbefore adoption723774a

line 431why, one step back
431 , body;

Changed `res.redirect()` signature to accept status first. Closes #832Tj Holowaychukbefore adoptione301d43

lines 432–437why, one step back
432
433 // allow status / url434 if (2 == arguments.length) {435 status = url;436 url = arguments[1];437 }

added quick start to guideTj Holowaychukbefore adoption723774a

lines 438–458why, one step back
438
439 // Setup redirect map440 var map = {441 back: req.header('Referrer', base)442 , home: base443 };444445 // Support custom redirect map446 map.__proto__ = app.redirects;447448 // Attempt mapped redirect449 var mapped = 'function' == typeof map[url]450 ? map[url](req, this)451 : map[url];452453 // Perform redirect454 url = mapped || url;455456 // Relative457 if (!~url.indexOf('://')) {458 // Respect mount-point

Merged basepath setting. Closes #813Tj Holowaychukbefore adoptione9abe1b

line 459why, one step back
459 if ('/' != base && 0 != url.indexOf(base)) url = base + url;

added quick start to guideTj Holowaychukbefore adoption723774a

lines 460–468why, one step back
460
461 // Absolute462 var host = req.headers.host463 , tls = req.connection.encrypted;464 url = 'http' + (tls ? 's' : '') + '://' + host + url;465 }466467 // Support text/{plain,html} by default468 if (req.accepts('html')) {

refactored `res.redirect()` slightlyTj Holowaychukbefore adoption6bd5182

line 469why, one step back
469 body = '<p>' + statusCodes[status] + '. Redirecting to <a href="' + url + '">' + url + '</a></p>';

added quick start to guideTj Holowaychukbefore adoption723774a

lines 470–471why, one step back
470 this.header('Content-Type', 'text/html');
471 } else {

refactored `res.redirect()` slightlyTj Holowaychukbefore adoption6bd5182

line 472why, one step back
472 body = statusCodes[status] + '. Redirecting to ' + url;

added quick start to guideTj Holowaychukbefore adoption723774a

lines 473–478why, one step back
473 this.header('Content-Type', 'text/plain');
474 }475476 // Respond477 this.statusCode = status;478 this.header('Location', url);

Fixed `res.redirect()` HEAD supportTj Holowaychukbefore adoptiond3937b9

line 479why, one step back
479 this.end(head ? null : body);

added quick start to guideTj Holowaychukbefore adoption723774a

line 480why, one step back
480};