Skip to content
Myr

auto set Content-Type in res.attachement

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

authored by Aaron Heckmann · committed by Tj Holowaychuk · parent 957cf45 · Browse files · 2 files+5 added−2 removed
This commit

State

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

Trailers

  • Signed-off-by: Tj Holowaychuk <tj@vision-media.ca>

Diff stats

2 files+5 added−2 removed

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

2 files+5 added−2 removed

modified:lib/response.js+1 added
174 unmodified lines
175 * @api public176 */177178res.attachment = function(filename){179 if (filename) this.contentType(filename);180 this.header('Content-Disposition', filename181 ? 'attachment; filename="' + path.basename(filename) + '"'182 : 'attachment');183 return this;
233 unmodified lines
modified:test/response.test.js+4 added-2 removed
205 unmodified lines
206 207 assert.response(app,208 { url: '/javascripts/jquery.js' },209 { body: 'whatever'210 , headers: { 'Content-Type': 'application/javascript'210 , headers: { 'Content-Disposition': 'attachment; filename="jquery.js"' }});211 , 'Content-Disposition': 'attachment; filename="jquery.js"' }});212213 assert.response(app,214 { url: '/style.css' },215 { body: 'some stylezzz'215 , headers: { 'Content-Disposition': 'attachment' }});216 , headers: { 'Content-Type': 'text/html; charset=utf-8'217 , 'Content-Disposition': 'attachment' }});218 },219 220 'test #redirect()': function(){221 var app = express.createServer()
388 unmodified lines