Skip to content
Myr

Merge branch 'redirect-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 · parents f37f9bf, 1507a39 · Browse files · 2 files+16 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+16 added−12 removed

  • tests:+11 added−10 removed
  • other:+5 added−2 removed

2 files+16 added−12 removed

modified:lib/express/response.js+5 added-2 removed
264 unmodified lines
265 ? map[url](this.req, this)266 : map[url];267268 // Perform redirect269 this.writeHead(status || 302, { 'Location': mapped || url });270 this.end();269 url = mapped || url;270 this.send('Redirecting to ' + url, {271 'Content-Type': 'text/plain',272 'Location': url273 }, status || 302);274};
modified:test/response.test.js+11 added-10 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,143 { url: '/' },143 { body: '', status: 301, headers: { Location: 'http://google.com' }});144 { body: 'Redirecting to http://google.com', status: 301, headers: { Location: 'http://google.com' }});145 assert.response(app,146 { url: '/back' },146 { body: '', status: 302, headers: { Location: '/' }});147 { body: 'Redirecting to /', status: 302, headers: { Location: '/', 'Content-Type': 'text/plain' }});148 assert.response(app,149 { url: '/back', headers: { Referer: '/foo' }},149 { body: '', status: 302, headers: { Location: '/foo' }});150 { body: 'Redirecting to /foo', status: 302, headers: { Location: '/foo' }});151 assert.response(app,152 { url: '/back', headers: { Referrer: '/foo' }},152 { body: '', status: 302, headers: { Location: '/foo' }});153 { body: 'Redirecting to /foo', status: 302, headers: { Location: '/foo' }});154 assert.response(app,155 { url: '/home' },155 { body: '', status: 302, headers: { Location: '/' }});156 { body: 'Redirecting to /', status: 302, headers: { Location: '/' }});157158 assert.response(app2,159 { url: '/' },159 { body: '', status: 301, headers: { Location: 'http://google.com' }});160 { body: 'Redirecting to http://google.com', status: 301, headers: { Location: 'http://google.com' }});161 assert.response(app2,162 { url: '/back' },162 { body: '', status: 302, headers: { Location: '/blog' }});163 { body: 'Redirecting to /blog', status: 302, headers: { Location: '/blog' }});164 assert.response(app2,165 { url: '/home' },165 { body: '', status: 302, headers: { Location: '/blog' }});166 { body: 'Redirecting to /blog', status: 302, headers: { Location: '/blog' }});167 assert.response(app2,168 { url: '/google' },168 { body: '', headers: { Location: 'http://google.com' }});169 { body: 'Redirecting to http://google.com', headers: { Location: 'http://google.com' }});170 assert.response(app2,171 { url: '/user/12' },171 { body: '', 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