Skip to content
Myr

response.test.js

This file

Path

test/response.test.js

587 lines · 15.6 KiB · JavaScript

Last changed by

Added test for res.contentType() literalTj Holowaychukbefore adoption1fe0aea

History of this file

Take it

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

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 1–6why, one step back
1
2/**3 * Module dependencies.4 */56var express = require('express')

Fixed res.download() callback, passing stream. Closes #528Tj Holowaychukbefore adoption07eb66c

line 7why, one step back
7 , Stream = require('stream').Stream

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 8–13why, one step back
8 , assert = require('assert')
9 , should = require('should');1011module.exports = {12 'test #send()': function(){13 var app = express.createServer();

fixed a testTj Holowaychukbefore adoption5df2544

line 14why, one step back
14

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 15–51why, one step back
15 app.get('/html', function(req, res){
16 res.send('<p>test</p>', { 'Content-Language': 'en' });17 });18 19 app.get('/json', function(req, res){20 res.header('X-Foo', 'bar');21 res.send({ foo: 'bar' }, { 'X-Foo': 'baz' }, 201);22 });23 24 app.get('/jsonp', function(req, res){25 app.enable('jsonp callback');26 res.header('X-Foo', 'bar');27 res.send({ foo: 'bar' }, { 'X-Foo': 'baz' }, 201);28 app.disable('jsonp callback');29 });30 31 app.get('/text', function(req, res){32 res.header('X-Foo', 'bar');33 res.contentType('.txt');34 res.send('wahoo');35 });36 37 app.get('/status', function(req, res){38 res.send(404);39 });40 41 app.get('/error', function(req, res){42 res.send('Oh shit!', { 'Content-Type': 'text/plain' }, 500);43 });44 45 app.get('/buffer', function(req, res){46 res.send(new Buffer('wahoo!'));47 });48 49 app.get('/noargs', function(req, res, next){50 res.send();51 });

fixed a testTj Holowaychukbefore adoption5df2544

line 52why, one step back
52

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 53–54why, one step back
53 assert.response(app,
54 { url: '/html' },

refactoring tstsTj Holowaychukbefore adoptionacb502e

lines 55–57why, one step back
55 { body: '<p>test</p>'
56 , headers: {57 'Content-Language': 'en'

default res.send() string charset to utf8Tj Holowaychukbefore adoptionacbf224

line 58why, one step back
58 , 'Content-Type': 'text/html; charset=utf8'

refactoring tstsTj Holowaychukbefore adoptionacb502e

line 59why, one step back
59 }});

fixed a testTj Holowaychukbefore adoption5df2544

line 60why, one step back
60

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 61–62why, one step back
61 assert.response(app,
62 { url: '/json' },

refactoring tstsTj Holowaychukbefore adoptionacb502e

lines 63–68why, one step back
63 { body: '{"foo":"bar"}'
64 , status: 20165 , headers: {66 'Content-Type': 'application/json'67 , 'X-Foo': 'baz'68 }});

fixed a testTj Holowaychukbefore adoption5df2544

line 69why, one step back
69

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 70–71why, one step back
70 assert.response(app,
71 { url: '/jsonp?callback=test' },

refactoring tstsTj Holowaychukbefore adoptionacb502e

lines 72–77why, one step back
72 { body: 'test({"foo":"bar"});'
73 , status: 20174 , headers: {75 'Content-Type': 'text/javascript'76 , 'X-Foo': 'baz'77 }});

fixed a testTj Holowaychukbefore adoption5df2544

line 78why, one step back
78

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 79–80why, one step back
79 assert.response(app,
80 { url: '/jsonp?callback=baz' },

refactoring tstsTj Holowaychukbefore adoptionacb502e

lines 81–85why, one step back
81 { body: 'baz({"foo":"bar"});'
82 , status: 201, headers: {83 'Content-Type': 'text/javascript'84 , 'X-Foo': 'baz'85 }});

fixed a testTj Holowaychukbefore adoption5df2544

line 86why, one step back
86

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

line 87why, one step back
87 assert.response(app,

Strip unsafe chars from jsonp callbacksTj Holowaychukbefore adoption482fb5b

line 88why, one step back
88 { url: '/jsonp?callback=invalid()[]' },

refactoring tstsTj Holowaychukbefore adoptionacb502e

lines 89–94why, one step back
89 { body: 'invalid({"foo":"bar"});'
90 , status: 20191 , headers: {92 'Content-Type': 'text/javascript'93 , 'X-Foo': 'baz'94 }});

fixed a testTj Holowaychukbefore adoption5df2544

line 95why, one step back
95

Strip unsafe chars from jsonp callbacksTj Holowaychukbefore adoption482fb5b

line 96why, one step back
96 assert.response(app,

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

line 97why, one step back
97 { url: '/json?callback=test' },

more test refactoringTj Holowaychukbefore adoptiona63b232

lines 98–103why, one step back
98 { body: '{"foo":"bar"}'
99 , status: 201100 , headers: {101 'Content-Type': 'application/json'102 , 'X-Foo': 'baz'103 }});

fixed a testTj Holowaychukbefore adoption5df2544

line 104why, one step back
104

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 105–106why, one step back
105 assert.response(app,
106 { url: '/text' },

more test refactoringTj Holowaychukbefore adoptiona63b232

lines 107–111why, one step back
107 { body: 'wahoo'
108 , headers: {109 'Content-Type': 'text/plain'110 , 'X-Foo': 'bar'111 }});

fixed a testTj Holowaychukbefore adoption5df2544

line 112why, one step back
112

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 113–114why, one step back
113 assert.response(app,
114 { url: '/status' },

more test refactoringTj Holowaychukbefore adoptiona63b232

lines 115–117why, one step back
115 { body: 'Not Found'
116 , status: 404117 , headers: { 'Content-Type': 'text/plain' }});

fixed a testTj Holowaychukbefore adoption5df2544

line 118why, one step back
118

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 119–120why, one step back
119 assert.response(app,
120 { url: '/error' },

more test refactoringTj Holowaychukbefore adoptiona63b232

lines 121–123why, one step back
121 { body: 'Oh shit!'
122 , status: 500123 , headers: {

fixed a testTj Holowaychukbefore adoption5df2544

line 124why, one step back
124 'Content-Type': 'text/plain; charset=utf8'

more test refactoringTj Holowaychukbefore adoptiona63b232

lines 125–126why, one step back
125 , 'Content-Length': '8'
126 }});

fixed a testTj Holowaychukbefore adoption5df2544

line 127why, one step back
127

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 128–129why, one step back
128 assert.response(app,
129 { url: '/buffer' },

more test refactoringTj Holowaychukbefore adoptiona63b232

lines 130–134why, one step back
130 { body: 'wahoo!'
131 , headers: {132 'Content-Type': 'application/octet-stream'133 , 'Content-Length': '6'134 }});

fixed a testTj Holowaychukbefore adoption5df2544

line 135why, one step back
135

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 136–156why, one step back
136 assert.response(app,
137 { url: '/noargs' },138 { status: 204 }, function(res){139 assert.equal(undefined, res.headers['content-type']);140 assert.equal(undefined, res.headers['content-length']);141 });142 },143 144 'test #contentType()': function(){145 var app = express.createServer();146 147 app.get('/html', function(req, res){148 res.contentType('index.html');149 res.writeHead(200, res.headers);150 res.end('<p>yay</p>');151 });152 153 app.get('/json', function(req, res, next){154 res.contentType('json');155 res.send('{"foo":"bar"}');156 });

Added test for res.contentType() literalTj Holowaychukbefore adoption1fe0aea

lines 157–165why, one step back
157
158 app.get('/literal', function(req, res){159 res.contentType('application/json');160 res.send('{"foo":"bar"}')161 });162163 assert.response(app,164 { url: '/literal' },165 { headers: { 'Content-Type': 'application/json' }});

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 166–167why, one step back
166 assert.response(app,
167 { url: '/html' },

Changed; charsets are no longer impliedTj Holowaychukbefore adoption9fc3499

line 168why, one step back
168 { body: '<p>yay</p>', headers: { 'Content-Type': 'text/html' }});

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 169–188why, one step back
169 assert.response(app,
170 { url: '/json' },171 { headers: { 'Content-Type': 'application/json' }});172 },173 174 'test #attachment()': function(){175 var app = express.createServer();176 177 app.get('/style.css', function(req, res){178 res.attachment();179 res.send('some stylezzz');180 });181182 app.get('/*', function(req, res){183 res.attachment(req.params[0]);184 res.send('whatever');185 });186 187 assert.response(app,188 { url: '/javascripts/jquery.js' },

more test refactoringTj Holowaychukbefore adoption7fd47c0

lines 189–191why, one step back
189 { body: 'whatever'
190 , headers: { 'Content-Disposition': 'attachment; filename="jquery.js"' }});191

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 192–193why, one step back
192 assert.response(app,
193 { url: '/style.css' },

more test refactoringTj Holowaychukbefore adoption7fd47c0

lines 194–195why, one step back
194 { body: 'some stylezzz'
195 , headers: { 'Content-Disposition': 'attachment' }});

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 196–251why, one step back
196 },
197 198 'test #redirect()': function(){199 var app = express.createServer()200 , app2 = express.createServer();201 202 app2.set('home', '/blog');203204 app2.redirect('google', 'http://google.com');205206 app2.redirect('blog', function(req, res){207 return req.params.id208 ? '/user/' + req.params.id + '/blog'209 : null;210 });211 212 app.get('/', function(req, res){213 res.redirect('http://google.com', 301);214 });215 216 app.get('/back', function(req, res){217 res.redirect('back');218 });219 220 app.get('/home', function(req, res){221 res.redirect('home');222 });223 224 app.get('/html', function(req, res){225 res.redirect('http://google.com');226 });227 228 app2.get('/', function(req, res){229 res.redirect('http://google.com', 301);230 });231 232 app2.get('/back', function(req, res){233 res.redirect('back');234 });235 236 app2.get('/home', function(req, res){237 res.redirect('home');238 });239 240 app2.get('/google', function(req, res){241 res.redirect('google');242 });243244 app2.get('/user/:id', function(req, res){245 res.header('X-Foo', 'bar');246 res.redirect('blog');247 });248249 assert.response(app,250 { url: '/html', headers: { Accept: 'text/html,text/plain' }},251 { body: '<p>Moved Temporarily. Redirecting to <a href="http://google.com">http://google.com</a></p>' });

more test refactoringTj Holowaychukbefore adoption7fd47c0

line 252why, one step back
252

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 253–254why, one step back
253 assert.response(app,
254 { url: '/', headers: { Accept: 'text/plain' }},

more test refactoringTj Holowaychukbefore adoption7fd47c0

lines 255–257why, one step back
255 { body: 'Moved Permanently. Redirecting to http://google.com'
256 , status: 301, headers: { Location: 'http://google.com' }});257

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 258–259why, one step back
258 assert.response(app,
259 { url: '/back', headers: { Accept: 'text/plain' }},

more test refactoringTj Holowaychukbefore adoption7fd47c0

lines 260–262why, one step back
260 { body: 'Moved Temporarily. Redirecting to /'
261 , status: 302, headers: { Location: '/', 'Content-Type': 'text/plain' }});262

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 263–264why, one step back
263 assert.response(app,
264 { url: '/back', headers: { Referer: '/foo', Accept: 'text/plain' }},

more test refactoringTj Holowaychukbefore adoption7fd47c0

lines 265–267why, one step back
265 { body: 'Moved Temporarily. Redirecting to /foo'
266 , status: 302, headers: { Location: '/foo' }});267

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 268–269why, one step back
268 assert.response(app,
269 { url: '/back', headers: { Referrer: '/foo', Accept: 'text/plain' }},

more test refactoringTj Holowaychukbefore adoption7fd47c0

lines 270–272why, one step back
270 { body: 'Moved Temporarily. Redirecting to /foo'
271 , status: 302, headers: { Location: '/foo' }});272

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 273–274why, one step back
273 assert.response(app,
274 { url: '/home', headers: { Accept: 'text/plain' } },

more test refactoringTj Holowaychukbefore adoption7fd47c0

lines 275–276why, one step back
275 { body: 'Moved Temporarily. Redirecting to /'
276 , status: 302, headers: { Location: '/' }});

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 277–279why, one step back
277
278 assert.response(app2,279 { url: '/', headers: { Accept: 'text/plain' }},

more test refactoringTj Holowaychukbefore adoption7fd47c0

lines 280–282why, one step back
280 { body: 'Moved Permanently. Redirecting to http://google.com'
281 , status: 301, headers: { Location: 'http://google.com' }});282

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 283–284why, one step back
283 assert.response(app2,
284 { url: '/back', headers: { Accept: 'text/plain' }},

more test refactoringTj Holowaychukbefore adoption7fd47c0

lines 285–287why, one step back
285 { body: 'Moved Temporarily. Redirecting to /blog'
286 , status: 302, headers: { Location: '/blog' }});287

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 288–289why, one step back
288 assert.response(app2,
289 { url: '/home', headers: { Accept: 'text/plain' }},

more test refactoringTj Holowaychukbefore adoption7fd47c0

lines 290–292why, one step back
290 { body: 'Moved Temporarily. Redirecting to /blog'
291 , status: 302, headers: { Location: '/blog' }});292

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 293–294why, one step back
293 assert.response(app2,
294 { url: '/google', headers: { Accept: 'text/plain' }},

more test refactoringTj Holowaychukbefore adoption7fd47c0

lines 295–297why, one step back
295 { body: 'Moved Temporarily. Redirecting to http://google.com'
296 , status: 302, headers: { Location: 'http://google.com' }});297

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 298–299why, one step back
298 assert.response(app2,
299 { url: '/user/12', headers: { Accept: 'text/plain' }},

more test refactoringTj Holowaychukbefore adoption7fd47c0

lines 300–301why, one step back
300 { body: 'Moved Temporarily. Redirecting to /user/12/blog'
301 , status: 302, headers: { Location: '/user/12/blog', 'X-Foo': 'bar' }});

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

line 302why, one step back
302 },

Added res.redirect() mount testTj Holowaychukbefore adoption99dcf75

lines 303–323why, one step back
303
304 'test #redirect() when mounted': function(){305 var app = express.createServer()306 , blog = express.createServer();307308309 blog.get('/posts', function(req, res){310 res.redirect('/posts/all');311 });312313 blog.get('/posts/all', function(req, res){314 res.send('all blog posts');315 });316317 app.use('/blog', blog);318319 assert.response(app,320 { url: '/blog/posts' },321 { status: 302322 , headers: { Location: '/blog/posts/all' }});323 },

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 324–329why, one step back
324
325 'test #sendfile()': function(){326 var app = express.createServer();327328 app.get('/*', function(req, res, next){329 var file = req.params[0]

refactoring to use connects static serverTj Holowaychukbefore adoption59a74ec

lines 330–331why, one step back
330 , path = __dirname + '/fixtures/' + file;
331 res.sendfile(path);

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 332–338why, one step back
332 });
333 334 app.use(express.errorHandler());335336 assert.response(app,337 { url: '/../express.test.js' },338 { body: 'Forbidden', status: 403 });

more test refactoringTj Holowaychukbefore adoptionef1c858

line 339why, one step back
339

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 340–341why, one step back
340 assert.response(app,
341 { url: '/user.json' },

more test refactoringTj Holowaychukbefore adoptionef1c858

lines 342–344why, one step back
342 { body: '{"name":"tj"}'
343 , status: 200, headers: { 'Content-Type': 'application/json' }});344

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 345–346why, one step back
345 assert.response(app,
346 { url: '/hello.haml' },

more test refactoringTj Holowaychukbefore adoptionef1c858

lines 347–349why, one step back
347 { body: '%p Hello World'
348 , status: 200, headers: { 'Content-Type': 'application/octet-stream' }});349

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 350–351why, one step back
350 assert.response(app,
351 { url: '/doesNotExist' },

refactoring to use connects static serverTj Holowaychukbefore adoption59a74ec

line 352why, one step back
352 { body: 'Cannot GET /doesNotExist', status: 404 });

more test refactoringTj Holowaychukbefore adoptionef1c858

line 353why, one step back
353

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 354–355why, one step back
354 assert.response(app,
355 { url: '/partials' },

refactoring to use connects static serverTj Holowaychukbefore adoption59a74ec

line 356why, one step back
356 { body: 'Cannot GET /partials', status: 404 });

more test refactoringTj Holowaychukbefore adoptionef1c858

line 357why, one step back
357

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 358–361why, one step back
358 assert.response(app,
359 { url: '/large.json' },360 { status: 200, headers: { 'Content-Type': 'application/json' }});361 },

res.download() and res.sendfile() using connect nowTj Holowaychukbefore adoption9b1cc75

lines 362–413why, one step back
362
363 'test #sendfile(path, callback)': function(beforeExit){364 var app = express.createServer()365 , calls = 0;366 367 app.get('/*', function(req, res, next){368 var file = req.params[0]369 , path = __dirname + '/fixtures/' + file;370 res.sendfile(path, function(err){371 if (err) return res.send('got an error');372 ++calls;373 });374 });375376 assert.response(app,377 { url: '/forum' },378 { body: 'got an error' });379380 assert.response(app,381 { url: '/does-not-exist' },382 { body: 'got an error' });383384 assert.response(app,385 { url: '/large.json' },386 { headers: { 'Accept-Ranges': 'bytes' }});387388 beforeExit(function(){389 calls.should.equal(1);390 });391 },392 393 'test #sendfile(path, options, callback)': function(beforeExit){394 var app = express.createServer()395 , calls = 0;396 397 app.get('/*', function(req, res, next){398 var file = req.params[0]399 , path = __dirname + '/fixtures/' + file;400 res.sendfile(path, { maxAge: 3600000 }, function(err){401 if (err) return res.send('got an error');402 ++calls;403 });404 });405406 assert.response(app,407 { url: '/does-not-exist' },408 { body: 'got an error' });409410 assert.response(app,411 { url: '/large.json' },412 { headers: {413 'Accept-Ranges': 'bytes'

fixed a testTj Holowaychukbefore adoptiona5b6929

line 414why, one step back
414 , 'Cache-Control': 'public, max-age=3600'

res.download() and res.sendfile() using connect nowTj Holowaychukbefore adoption9b1cc75

lines 415–420why, one step back
415 }});
416417 beforeExit(function(){418 calls.should.equal(1);419 });420 },

refactoring to use connects static serverTj Holowaychukbefore adoption59a74ec

lines 421–451why, one step back
421
422 'test #sendfile() Accept-Ranges': function(){423 var app = express.createServer();424 425 app.get('/*', function(req, res, next){426 var file = req.params[0]427 , path = __dirname + '/fixtures/' + file;428 res.sendfile(path);429 });430 431 assert.response(app,432 { url: '/large.json' },433 { headers: { 'Accept-Ranges': 'bytes' }});434 },435 436 'test #sendfile() Range': function(){437 var app = express.createServer();438 439 app.get('/*', function(req, res, next){440 var file = req.params[0]441 , path = __dirname + '/fixtures/' + file;442 res.sendfile(path);443 });444 445 assert.response(app,446 { url: '/large.json', headers: { 'Range': 'bytes=0-499' }},447 { headers: {448 'Content-Type': 'application/json',449 'Content-Range': 'bytes 0-499/2535'450 }, status: 206 });451 },

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

line 452why, one step back
452

refactoring to use connects static serverTj Holowaychukbefore adoption59a74ec

line 453why, one step back
453 'test #sendfile() Range invalid syntax': function(){

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 454–463why, one step back
454 var app = express.createServer();
455 456 app.get('/*', function(req, res, next){457 var file = req.params[0]458 , path = __dirname + '/fixtures/' + file;459 res.sendfile(path);460 });461 462 assert.response(app,463 { url: '/large.json', headers: { 'Range': 'basdytes=asdf' }},

Added 416 support to res.sendfile()Tj Holowaychukbefore adoptione7df82f

line 464why, one step back
464 { body: 'Requested Range Not Satisfiable', status: 416 });

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

line 465why, one step back
465 },

refactoring to use connects static serverTj Holowaychukbefore adoption59a74ec

line 466why, one step back
466

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 467–474why, one step back
467 'test #sendfile() Range invalid range': function(){
468 var app = express.createServer();469 470 app.get('/*', function(req, res, next){471 var file = req.params[0]472 , path = __dirname + '/fixtures/' + file;473 res.sendfile(path);474 });

refactoring to use connects static serverTj Holowaychukbefore adoption59a74ec

line 475why, one step back
475

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 476–477why, one step back
476 assert.response(app,
477 { url: '/large.json', headers: { 'Range': 'bytes=500-10' }},

Added 416 support to res.sendfile()Tj Holowaychukbefore adoptione7df82f

line 478why, one step back
478 { body: 'Requested Range Not Satisfiable', status: 416 });

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 479–480why, one step back
479 },
480

res.download() and res.sendfile() using connect nowTj Holowaychukbefore adoption9b1cc75

lines 481–483why, one step back
481 'test #download()': function(beforeExit){
482 var app = express.createServer()483 , calls = 0;

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 484–485why, one step back
484
485 app.get('/json', function(req, res, next){

res.download() and res.sendfile() using connect nowTj Holowaychukbefore adoption9b1cc75

lines 486–487why, one step back
486 var path = __dirname + '/fixtures/user.json';
487 res.download(path, 'account.json');

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

line 488why, one step back
488 });

res.download() and res.sendfile() using connect nowTj Holowaychukbefore adoption9b1cc75

lines 489–495why, one step back
489
490 app.get('/callback', function(req, res, next){491 res.download(__dirname + '/fixtures/pets.json', function(err){492 ++calls;493 });494 });495

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 496–498why, one step back
496 app.get('/*', function(req, res, next){
497 res.download(__dirname + '/fixtures/' + req.params[0]);498 });

res.download() and res.sendfile() using connect nowTj Holowaychukbefore adoption9b1cc75

line 499why, one step back
499

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

line 500why, one step back
500 assert.response(app,

res.download() and res.sendfile() using connect nowTj Holowaychukbefore adoption9b1cc75

lines 501–504why, one step back
501 { url: '/callback' },
502 { body: '["tobi", "loki", "jane"]' });503504 assert.response(app,

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 505–509why, one step back
505 { url: '/user.json' },
506 { body: '{"name":"tj"}', status: 200, headers: {507 'Content-Type': 'application/json',508 'Content-Disposition': 'attachment; filename="user.json"'509 }});

refactoring to use connects static serverTj Holowaychukbefore adoption59a74ec

line 510why, one step back
510

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 511–523why, one step back
511 assert.response(app,
512 { url: '/json' },513 { body: '{"name":"tj"}', status: 200, headers: {514 'Content-Type': 'application/json',515 'Content-Length': '13',516 'Content-Disposition': 'attachment; filename="account.json"'517 }});518 519 assert.response(app,520 { url: '/missing' },521 function(res){522 assert.equal(null, res.headers['content-disposition']);523 });

res.download() and res.sendfile() using connect nowTj Holowaychukbefore adoption9b1cc75

lines 524–527why, one step back
524
525 beforeExit(function(){526 calls.should.equal(1);527 });

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 528–534why, one step back
528 },
529 530 'test #cookie()': function(){531 var app = express.createServer();532 533 app.get('/', function(req, res){534 res.cookie('rememberme', 'yes', { expires: new Date(1), httpOnly: true });

Added multiple Set-Cookie header testsTj Holowaychukbefore adoption80c3b98

line 535why, one step back
535 res.cookie('something', 'else');

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 536–537why, one step back
536 res.redirect('/');
537 });

Added res.cookie() maxAge supportTj Holowaychukbefore adoption4c274c5

line 538why, one step back
538

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 539–542why, one step back
539 assert.response(app,
540 { url: '/' },541 function(res){542 res.headers['set-cookie']

Added multiple Set-Cookie header testsTj Holowaychukbefore adoption80c3b98

line 543why, one step back
543 .should.eql(['rememberme=yes; expires=Thu, 01 Jan 1970 00:00:00 GMT; httpOnly', 'something=else']);

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 544–558why, one step back
544 });
545 },546 547 'test #clearCookie()': function(){548 var app = express.createServer();549 550 app.get('/', function(req, res){551 res.clearCookie('rememberme');552 res.redirect('/');553 });554 555 assert.response(app,556 { url: '/' },557 function(res){558 res.headers['set-cookie']

Fixed two testsTj Holowaychukbefore adoptiondf49769

line 559why, one step back
559 .should.eql(['rememberme=; expires=Thu, 01 Jan 1970 00:00:00 GMT']);

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 560–572why, one step back
560 });
561 },562 563 'test HEAD': function(){564 var app = express.createServer();565 566 app.get('/', function(req, res, next){567 res.send('Hello World');568 });569 570 assert.response(app,571 { url: '/', method: 'HEAD' },572 { body: '', headers: { 'Content-Length': 11 }});

Added .charset + res.send() testTj Holowaychukbefore adoption820b43c

lines 573–574why, one step back
573 },
574

added charset test with res.render()Tj Holowaychukbefore adoptionbac62df

line 575why, one step back
575 'test .charset with res.send()': function(){

Added .charset + res.send() testTj Holowaychukbefore adoption820b43c

lines 576–578why, one step back
576 var app = express.createServer();
577578 app.get('/', function(req, res){

charset tests using ISO-8859-1Tj Holowaychukbefore adoptiond0d17a0

line 579why, one step back
579 res.charset = 'ISO-8859-1';

Added .charset + res.send() testTj Holowaychukbefore adoption820b43c

line 580why, one step back
580 res.send('<p>hey</p>');

added charset test with res.render()Tj Holowaychukbefore adoptionbac62df

lines 581–584why, one step back
581 });
582583 assert.response(app,584 { url: '/' },

charset tests using ISO-8859-1Tj Holowaychukbefore adoptiond0d17a0

line 585why, one step back
585 { headers: { 'Content-Type': 'text/html; charset=ISO-8859-1' }});

Updated connect submoduleTj Holowaychukbefore adoptiona9db47f

lines 586–587why, one step back
586 }
587};