Added res.redirect() response bodies
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent f37f9bf · Browse files · 2 files·+13 added−12 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+13 added−12 removed
- tests:+10 added−10 removed
- other:+3 added−2 removed
Provenance
- Commit
be1541a- Tree
d9672b8- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
f37f9bf
2 files changed+13 added−12 removed
modified:lib/express/response.js+3 added-2 removed
264 unmodified lines265 ? map[url](this.req, this)266 : map[url];267 268 // Perform redirect269+ url = mapped || url;269- this.writeHead(status || 302, { 'Location': mapped || url });270- this.end();270+ this.writeHead(status || 302, { 'Location': url });271+ this.end('Redirecting to ' + url);272 };modified:test/response.test.js+10 added-10 removed
138 unmodified lines139 });140 141 assert.response(app,142 { url: '/' },143- { body: '', status: 301, headers: { Location: 'http://google.com' }});143+ { body: 'Redirecting to http://google.com', status: 301, headers: { Location: 'http://google.com' }});144 assert.response(app,145 { url: '/back' },146- { body: '', status: 302, headers: { Location: '/' }});146+ { body: 'Redirecting to /', status: 302, headers: { Location: '/' }});147 assert.response(app,148 { url: '/back', headers: { Referer: '/foo' }},149- { body: '', status: 302, headers: { Location: '/foo' }});149+ { body: 'Redirecting to /foo', status: 302, headers: { Location: '/foo' }});150 assert.response(app,151 { url: '/back', headers: { Referrer: '/foo' }},152- { body: '', status: 302, headers: { Location: '/foo' }});152+ { body: 'Redirecting to /foo', status: 302, headers: { Location: '/foo' }});153 assert.response(app,154 { url: '/home' },155- { body: '', status: 302, headers: { Location: '/' }});155+ { body: 'Redirecting to /', status: 302, headers: { Location: '/' }});156 157 assert.response(app2,158 { url: '/' },159- { body: '', status: 301, headers: { Location: 'http://google.com' }});159+ { body: 'Redirecting to http://google.com', status: 301, headers: { Location: 'http://google.com' }});160 assert.response(app2,161 { url: '/back' },162- { body: '', status: 302, headers: { Location: '/blog' }});162+ { body: 'Redirecting to /blog', status: 302, headers: { Location: '/blog' }});163 assert.response(app2,164 { url: '/home' },165- { body: '', status: 302, headers: { Location: '/blog' }});165+ { body: 'Redirecting to /blog', status: 302, headers: { Location: '/blog' }});166 assert.response(app2,167 { url: '/google' },168- { body: '', headers: { Location: 'http://google.com' }});168+ { body: 'Redirecting to http://google.com', headers: { Location: 'http://google.com' }});169 assert.response(app2,170 { url: '/user/12' },171- { body: '', headers: { Location: '/user/12/blog' }});171+ { body: 'Redirecting to /user/12/blog', headers: { Location: '/user/12/blog' }});172 },173 174 'test #sendfile()': function(assert){175 var app = express.createServer();55 unmodified lines