Skip to content
Myr

res.redirect() using res.send()

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

Allows for setting of arbitrary headers via res.header()

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent e640565 · Browse files · 2 files+6 added−3 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+6 added−3 removed

  • tests:+2 added−1 removed
  • other:+4 added−2 removed

2 files+6 added−3 removed

modified:lib/express/response.js+4 added-2 removed
265 unmodified lines
266 : map[url];267268 // Perform redirect269 url = mapped || url;270 this.writeHead(status || 302, { 'Content-Type': 'text/plain', 'Location': url });271 this.end('Redirecting to ' + url);270 this.send('Redirecting to ' + url, {271 'Content-Type': 'text/plain',272 'Location': url273 }, status || 302);274};
modified:test/response.test.js+2 added-1 removed
133 unmodified lines
134 res.redirect('google');135 });136137 app2.get('/user/:id', function(req, res){138 res.header('X-Foo', 'bar');139 res.redirect('blog');140 });141 142 assert.response(app,
25 unmodified lines
168 { url: '/google' },169 { body: 'Redirecting to http://google.com', headers: { Location: 'http://google.com' }});170 assert.response(app2,171 { url: '/user/12' },171 { body: 'Redirecting to /user/12/blog', headers: { Location: '/user/12/blog' }});172 { body: 'Redirecting to /user/12/blog', headers: { Location: '/user/12/blog', 'X-Foo': 'bar' }});173 },174 175 'test #sendfile()': function(assert){176 var app = express.createServer();
55 unmodified lines