response.test.js
This file
Path
test/response.test.js
579 lines · 15.3 KiB · JavaScript
Last changed by
default res.send() string charset to utf8Tj Holowaychukbefore adoptionacbf224
History of this fileTake it
The walk stopped after 200 commits: lines older than 5ac0c6d point at it.
Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 1–6why, one step back12/**3 * Module dependencies.4 */56var express = require('express')Fixed res.download() callback, passing stream. Closes #528Tj Holowaychukbefore adoption07eb66c
line 7why, one step back7 , Stream = require('stream').StreamAdded res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 8–54why, one step back8 , assert = require('assert')9 , should = require('should');1011module.exports = {12 'test #send()': function(){13 var app = express.createServer();1415 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 });5253 assert.response(app,54 { url: '/html' },refactoring tstsTj Holowaychukbefore adoptionacb502e
lines 55–57why, one step back55 { body: '<p>test</p>'56 , headers: {57 'Content-Language': 'en'default res.send() string charset to utf8Tj Holowaychukbefore adoptionacbf224
line 58why, one step back58 , 'Content-Type': 'text/html; charset=utf8'refactoring tstsTj Holowaychukbefore adoptionacb502e
lines 59–60why, one step back59 }});60Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 61–62why, one step back61 assert.response(app,62 { url: '/json' },refactoring tstsTj Holowaychukbefore adoptionacb502e
lines 63–68why, one step back63 { body: '{"foo":"bar"}'64 , status: 20165 , headers: {66 'Content-Type': 'application/json'67 , 'X-Foo': 'baz'68 }});Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 69–71why, one step back6970 assert.response(app,71 { url: '/jsonp?callback=test' },refactoring tstsTj Holowaychukbefore adoptionacb502e
lines 72–77why, one step back72 { body: 'test({"foo":"bar"});'73 , status: 20174 , headers: {75 'Content-Type': 'text/javascript'76 , 'X-Foo': 'baz'77 }});Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 78–80why, one step back7879 assert.response(app,80 { url: '/jsonp?callback=baz' },refactoring tstsTj Holowaychukbefore adoptionacb502e
lines 81–85why, one step back81 { body: 'baz({"foo":"bar"});'82 , status: 201, headers: {83 'Content-Type': 'text/javascript'84 , 'X-Foo': 'baz'85 }});Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 86–87why, one step back8687 assert.response(app,Strip unsafe chars from jsonp callbacksTj Holowaychukbefore adoption482fb5b
line 88why, one step back88 { url: '/jsonp?callback=invalid()[]' },refactoring tstsTj Holowaychukbefore adoptionacb502e
lines 89–94why, one step back89 { body: 'invalid({"foo":"bar"});'90 , status: 20191 , headers: {92 'Content-Type': 'text/javascript'93 , 'X-Foo': 'baz'94 }});Strip unsafe chars from jsonp callbacksTj Holowaychukbefore adoption482fb5b
lines 95–96why, one step back9596 assert.response(app,Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
line 97why, one step back97 { url: '/json?callback=test' },more test refactoringTj Holowaychukbefore adoptiona63b232
lines 98–103why, one step back98 { body: '{"foo":"bar"}'99 , status: 201100 , headers: {101 'Content-Type': 'application/json'102 , 'X-Foo': 'baz'103 }});Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 104–106why, one step back104105 assert.response(app,106 { url: '/text' },more test refactoringTj Holowaychukbefore adoptiona63b232
lines 107–112why, one step back107 { body: 'wahoo'108 , headers: {109 'Content-Type': 'text/plain'110 , 'X-Foo': 'bar'111 }});112Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 113–114why, one step back113 assert.response(app,114 { url: '/status' },more test refactoringTj Holowaychukbefore adoptiona63b232
lines 115–118why, one step back115 { body: 'Not Found'116 , status: 404117 , headers: { 'Content-Type': 'text/plain' }});118Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 119–120why, one step back119 assert.response(app,120 { url: '/error' },more test refactoringTj Holowaychukbefore adoptiona63b232
lines 121–127why, one step back121 { body: 'Oh shit!'122 , status: 500123 , headers: {124 'Content-Type': 'text/plain'125 , 'Content-Length': '8'126 }});127Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 128–129why, one step back128 assert.response(app,129 { url: '/buffer' },more test refactoringTj Holowaychukbefore adoptiona63b232
lines 130–135why, one step back130 { body: 'wahoo!'131 , headers: {132 'Content-Type': 'application/octet-stream'133 , 'Content-Length': '6'134 }});135Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 136–159why, one step back136 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 });157 158 assert.response(app,159 { url: '/html' },Changed; charsets are no longer impliedTj Holowaychukbefore adoption9fc3499
line 160why, one step back160 { body: '<p>yay</p>', headers: { 'Content-Type': 'text/html' }});Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 161–180why, one step back161 assert.response(app,162 { url: '/json' },163 { headers: { 'Content-Type': 'application/json' }});164 },165 166 'test #attachment()': function(){167 var app = express.createServer();168 169 app.get('/style.css', function(req, res){170 res.attachment();171 res.send('some stylezzz');172 });173174 app.get('/*', function(req, res){175 res.attachment(req.params[0]);176 res.send('whatever');177 });178 179 assert.response(app,180 { url: '/javascripts/jquery.js' },more test refactoringTj Holowaychukbefore adoption7fd47c0
lines 181–183why, one step back181 { body: 'whatever'182 , headers: { 'Content-Disposition': 'attachment; filename="jquery.js"' }});183Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 184–185why, one step back184 assert.response(app,185 { url: '/style.css' },more test refactoringTj Holowaychukbefore adoption7fd47c0
lines 186–187why, one step back186 { body: 'some stylezzz'187 , headers: { 'Content-Disposition': 'attachment' }});Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 188–243why, one step back188 },189 190 'test #redirect()': function(){191 var app = express.createServer()192 , app2 = express.createServer();193 194 app2.set('home', '/blog');195196 app2.redirect('google', 'http://google.com');197198 app2.redirect('blog', function(req, res){199 return req.params.id200 ? '/user/' + req.params.id + '/blog'201 : null;202 });203 204 app.get('/', function(req, res){205 res.redirect('http://google.com', 301);206 });207 208 app.get('/back', function(req, res){209 res.redirect('back');210 });211 212 app.get('/home', function(req, res){213 res.redirect('home');214 });215 216 app.get('/html', function(req, res){217 res.redirect('http://google.com');218 });219 220 app2.get('/', function(req, res){221 res.redirect('http://google.com', 301);222 });223 224 app2.get('/back', function(req, res){225 res.redirect('back');226 });227 228 app2.get('/home', function(req, res){229 res.redirect('home');230 });231 232 app2.get('/google', function(req, res){233 res.redirect('google');234 });235236 app2.get('/user/:id', function(req, res){237 res.header('X-Foo', 'bar');238 res.redirect('blog');239 });240241 assert.response(app,242 { url: '/html', headers: { Accept: 'text/html,text/plain' }},243 { body: '<p>Moved Temporarily. Redirecting to <a href="http://google.com">http://google.com</a></p>' });more test refactoringTj Holowaychukbefore adoption7fd47c0
line 244why, one step back244Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 245–246why, one step back245 assert.response(app,246 { url: '/', headers: { Accept: 'text/plain' }},more test refactoringTj Holowaychukbefore adoption7fd47c0
lines 247–249why, one step back247 { body: 'Moved Permanently. Redirecting to http://google.com'248 , status: 301, headers: { Location: 'http://google.com' }});249Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 250–251why, one step back250 assert.response(app,251 { url: '/back', headers: { Accept: 'text/plain' }},more test refactoringTj Holowaychukbefore adoption7fd47c0
lines 252–254why, one step back252 { body: 'Moved Temporarily. Redirecting to /'253 , status: 302, headers: { Location: '/', 'Content-Type': 'text/plain' }});254Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 255–256why, one step back255 assert.response(app,256 { url: '/back', headers: { Referer: '/foo', Accept: 'text/plain' }},more test refactoringTj Holowaychukbefore adoption7fd47c0
lines 257–259why, one step back257 { body: 'Moved Temporarily. Redirecting to /foo'258 , status: 302, headers: { Location: '/foo' }});259Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 260–261why, one step back260 assert.response(app,261 { url: '/back', headers: { Referrer: '/foo', Accept: 'text/plain' }},more test refactoringTj Holowaychukbefore adoption7fd47c0
lines 262–264why, one step back262 { body: 'Moved Temporarily. Redirecting to /foo'263 , status: 302, headers: { Location: '/foo' }});264Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 265–266why, one step back265 assert.response(app,266 { url: '/home', headers: { Accept: 'text/plain' } },more test refactoringTj Holowaychukbefore adoption7fd47c0
lines 267–268why, one step back267 { body: 'Moved Temporarily. Redirecting to /'268 , status: 302, headers: { Location: '/' }});Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 269–271why, one step back269270 assert.response(app2,271 { url: '/', headers: { Accept: 'text/plain' }},more test refactoringTj Holowaychukbefore adoption7fd47c0
lines 272–274why, one step back272 { body: 'Moved Permanently. Redirecting to http://google.com'273 , status: 301, headers: { Location: 'http://google.com' }});274Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 275–276why, one step back275 assert.response(app2,276 { url: '/back', headers: { Accept: 'text/plain' }},more test refactoringTj Holowaychukbefore adoption7fd47c0
lines 277–279why, one step back277 { body: 'Moved Temporarily. Redirecting to /blog'278 , status: 302, headers: { Location: '/blog' }});279Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 280–281why, one step back280 assert.response(app2,281 { url: '/home', headers: { Accept: 'text/plain' }},more test refactoringTj Holowaychukbefore adoption7fd47c0
lines 282–284why, one step back282 { body: 'Moved Temporarily. Redirecting to /blog'283 , status: 302, headers: { Location: '/blog' }});284Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 285–286why, one step back285 assert.response(app2,286 { url: '/google', headers: { Accept: 'text/plain' }},more test refactoringTj Holowaychukbefore adoption7fd47c0
lines 287–289why, one step back287 { body: 'Moved Temporarily. Redirecting to http://google.com'288 , status: 302, headers: { Location: 'http://google.com' }});289Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 290–291why, one step back290 assert.response(app2,291 { url: '/user/12', headers: { Accept: 'text/plain' }},more test refactoringTj Holowaychukbefore adoption7fd47c0
lines 292–293why, one step back292 { body: 'Moved Temporarily. Redirecting to /user/12/blog'293 , status: 302, headers: { Location: '/user/12/blog', 'X-Foo': 'bar' }});Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
line 294why, one step back294 },Added res.redirect() mount testTj Holowaychukbefore adoption99dcf75
lines 295–315why, one step back295296 'test #redirect() when mounted': function(){297 var app = express.createServer()298 , blog = express.createServer();299300301 blog.get('/posts', function(req, res){302 res.redirect('/posts/all');303 });304305 blog.get('/posts/all', function(req, res){306 res.send('all blog posts');307 });308309 app.use('/blog', blog);310311 assert.response(app,312 { url: '/blog/posts' },313 { status: 302314 , headers: { Location: '/blog/posts/all' }});315 },Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 316–321why, one step back316 317 'test #sendfile()': function(){318 var app = express.createServer();319320 app.get('/*', function(req, res, next){321 var file = req.params[0]refactoring to use connects static serverTj Holowaychukbefore adoption59a74ec
lines 322–323why, one step back322 , path = __dirname + '/fixtures/' + file;323 res.sendfile(path);Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 324–330why, one step back324 });325 326 app.use(express.errorHandler());327328 assert.response(app,329 { url: '/../express.test.js' },330 { body: 'Forbidden', status: 403 });more test refactoringTj Holowaychukbefore adoptionef1c858
line 331why, one step back331Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 332–333why, one step back332 assert.response(app,333 { url: '/user.json' },more test refactoringTj Holowaychukbefore adoptionef1c858
lines 334–336why, one step back334 { body: '{"name":"tj"}'335 , status: 200, headers: { 'Content-Type': 'application/json' }});336Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 337–338why, one step back337 assert.response(app,338 { url: '/hello.haml' },more test refactoringTj Holowaychukbefore adoptionef1c858
lines 339–341why, one step back339 { body: '%p Hello World'340 , status: 200, headers: { 'Content-Type': 'application/octet-stream' }});341Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 342–343why, one step back342 assert.response(app,343 { url: '/doesNotExist' },refactoring to use connects static serverTj Holowaychukbefore adoption59a74ec
line 344why, one step back344 { body: 'Cannot GET /doesNotExist', status: 404 });more test refactoringTj Holowaychukbefore adoptionef1c858
line 345why, one step back345Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 346–347why, one step back346 assert.response(app,347 { url: '/partials' },refactoring to use connects static serverTj Holowaychukbefore adoption59a74ec
line 348why, one step back348 { body: 'Cannot GET /partials', status: 404 });more test refactoringTj Holowaychukbefore adoptionef1c858
line 349why, one step back349Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 350–353why, one step back350 assert.response(app,351 { url: '/large.json' },352 { status: 200, headers: { 'Content-Type': 'application/json' }});353 },res.download() and res.sendfile() using connect nowTj Holowaychukbefore adoption9b1cc75
lines 354–405why, one step back354 355 'test #sendfile(path, callback)': function(beforeExit){356 var app = express.createServer()357 , calls = 0;358 359 app.get('/*', function(req, res, next){360 var file = req.params[0]361 , path = __dirname + '/fixtures/' + file;362 res.sendfile(path, function(err){363 if (err) return res.send('got an error');364 ++calls;365 });366 });367368 assert.response(app,369 { url: '/forum' },370 { body: 'got an error' });371372 assert.response(app,373 { url: '/does-not-exist' },374 { body: 'got an error' });375376 assert.response(app,377 { url: '/large.json' },378 { headers: { 'Accept-Ranges': 'bytes' }});379380 beforeExit(function(){381 calls.should.equal(1);382 });383 },384 385 'test #sendfile(path, options, callback)': function(beforeExit){386 var app = express.createServer()387 , calls = 0;388 389 app.get('/*', function(req, res, next){390 var file = req.params[0]391 , path = __dirname + '/fixtures/' + file;392 res.sendfile(path, { maxAge: 3600000 }, function(err){393 if (err) return res.send('got an error');394 ++calls;395 });396 });397398 assert.response(app,399 { url: '/does-not-exist' },400 { body: 'got an error' });401402 assert.response(app,403 { url: '/large.json' },404 { headers: {405 'Accept-Ranges': 'bytes'fixed a testTj Holowaychukbefore adoptiona5b6929
line 406why, one step back406 , 'Cache-Control': 'public, max-age=3600'res.download() and res.sendfile() using connect nowTj Holowaychukbefore adoption9b1cc75
lines 407–412why, one step back407 }});408409 beforeExit(function(){410 calls.should.equal(1);411 });412 },refactoring to use connects static serverTj Holowaychukbefore adoption59a74ec
lines 413–443why, one step back413 414 'test #sendfile() Accept-Ranges': function(){415 var app = express.createServer();416 417 app.get('/*', function(req, res, next){418 var file = req.params[0]419 , path = __dirname + '/fixtures/' + file;420 res.sendfile(path);421 });422 423 assert.response(app,424 { url: '/large.json' },425 { headers: { 'Accept-Ranges': 'bytes' }});426 },427 428 'test #sendfile() Range': function(){429 var app = express.createServer();430 431 app.get('/*', function(req, res, next){432 var file = req.params[0]433 , path = __dirname + '/fixtures/' + file;434 res.sendfile(path);435 });436 437 assert.response(app,438 { url: '/large.json', headers: { 'Range': 'bytes=0-499' }},439 { headers: {440 'Content-Type': 'application/json',441 'Content-Range': 'bytes 0-499/2535'442 }, status: 206 });443 },Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
line 444why, one step back444 refactoring to use connects static serverTj Holowaychukbefore adoption59a74ec
line 445why, one step back445 'test #sendfile() Range invalid syntax': function(){Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 446–455why, one step back446 var app = express.createServer();447 448 app.get('/*', function(req, res, next){449 var file = req.params[0]450 , path = __dirname + '/fixtures/' + file;451 res.sendfile(path);452 });453 454 assert.response(app,455 { url: '/large.json', headers: { 'Range': 'basdytes=asdf' }},Added 416 support to res.sendfile()Tj Holowaychukbefore adoptione7df82f
line 456why, one step back456 { body: 'Requested Range Not Satisfiable', status: 416 });Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
line 457why, one step back457 },refactoring to use connects static serverTj Holowaychukbefore adoption59a74ec
line 458why, one step back458 Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 459–466why, one step back459 'test #sendfile() Range invalid range': function(){460 var app = express.createServer();461 462 app.get('/*', function(req, res, next){463 var file = req.params[0]464 , path = __dirname + '/fixtures/' + file;465 res.sendfile(path);466 });refactoring to use connects static serverTj Holowaychukbefore adoption59a74ec
line 467why, one step back467 Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 468–469why, one step back468 assert.response(app,469 { url: '/large.json', headers: { 'Range': 'bytes=500-10' }},Added 416 support to res.sendfile()Tj Holowaychukbefore adoptione7df82f
line 470why, one step back470 { body: 'Requested Range Not Satisfiable', status: 416 });Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 471–472why, one step back471 },472 res.download() and res.sendfile() using connect nowTj Holowaychukbefore adoption9b1cc75
lines 473–475why, one step back473 'test #download()': function(beforeExit){474 var app = express.createServer()475 , calls = 0;Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 476–477why, one step back476 477 app.get('/json', function(req, res, next){res.download() and res.sendfile() using connect nowTj Holowaychukbefore adoption9b1cc75
lines 478–479why, one step back478 var path = __dirname + '/fixtures/user.json';479 res.download(path, 'account.json');Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
line 480why, one step back480 });res.download() and res.sendfile() using connect nowTj Holowaychukbefore adoption9b1cc75
lines 481–487why, one step back481482 app.get('/callback', function(req, res, next){483 res.download(__dirname + '/fixtures/pets.json', function(err){484 ++calls;485 });486 });487Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 488–490why, one step back488 app.get('/*', function(req, res, next){489 res.download(__dirname + '/fixtures/' + req.params[0]);490 });res.download() and res.sendfile() using connect nowTj Holowaychukbefore adoption9b1cc75
line 491why, one step back491Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
line 492why, one step back492 assert.response(app,res.download() and res.sendfile() using connect nowTj Holowaychukbefore adoption9b1cc75
lines 493–496why, one step back493 { url: '/callback' },494 { body: '["tobi", "loki", "jane"]' });495496 assert.response(app,Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 497–501why, one step back497 { url: '/user.json' },498 { body: '{"name":"tj"}', status: 200, headers: {499 'Content-Type': 'application/json',500 'Content-Disposition': 'attachment; filename="user.json"'501 }});refactoring to use connects static serverTj Holowaychukbefore adoption59a74ec
line 502why, one step back502 Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 503–515why, one step back503 assert.response(app,504 { url: '/json' },505 { body: '{"name":"tj"}', status: 200, headers: {506 'Content-Type': 'application/json',507 'Content-Length': '13',508 'Content-Disposition': 'attachment; filename="account.json"'509 }});510 511 assert.response(app,512 { url: '/missing' },513 function(res){514 assert.equal(null, res.headers['content-disposition']);515 });res.download() and res.sendfile() using connect nowTj Holowaychukbefore adoption9b1cc75
lines 516–519why, one step back516517 beforeExit(function(){518 calls.should.equal(1);519 });Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 520–526why, one step back520 },521 522 'test #cookie()': function(){523 var app = express.createServer();524 525 app.get('/', function(req, res){526 res.cookie('rememberme', 'yes', { expires: new Date(1), httpOnly: true });Added multiple Set-Cookie header testsTj Holowaychukbefore adoption80c3b98
line 527why, one step back527 res.cookie('something', 'else');Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 528–529why, one step back528 res.redirect('/');529 });Added res.cookie() maxAge supportTj Holowaychukbefore adoption4c274c5
line 530why, one step back530Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 531–534why, one step back531 assert.response(app,532 { url: '/' },533 function(res){534 res.headers['set-cookie']Added multiple Set-Cookie header testsTj Holowaychukbefore adoption80c3b98
line 535why, one step back535 .should.eql(['rememberme=yes; expires=Thu, 01 Jan 1970 00:00:00 GMT; httpOnly', 'something=else']);Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 536–550why, one step back536 });537 },538 539 'test #clearCookie()': function(){540 var app = express.createServer();541 542 app.get('/', function(req, res){543 res.clearCookie('rememberme');544 res.redirect('/');545 });546 547 assert.response(app,548 { url: '/' },549 function(res){550 res.headers['set-cookie']Fixed two testsTj Holowaychukbefore adoptiondf49769
line 551why, one step back551 .should.eql(['rememberme=; expires=Thu, 01 Jan 1970 00:00:00 GMT']);Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 552–564why, one step back552 });553 },554 555 'test HEAD': function(){556 var app = express.createServer();557 558 app.get('/', function(req, res, next){559 res.send('Hello World');560 });561 562 assert.response(app,563 { url: '/', method: 'HEAD' },564 { body: '', headers: { 'Content-Length': 11 }});Added .charset + res.send() testTj Holowaychukbefore adoption820b43c
lines 565–566why, one step back565 },566 added charset test with res.render()Tj Holowaychukbefore adoptionbac62df
line 567why, one step back567 'test .charset with res.send()': function(){Added .charset + res.send() testTj Holowaychukbefore adoption820b43c
lines 568–570why, one step back568 var app = express.createServer();569570 app.get('/', function(req, res){charset tests using ISO-8859-1Tj Holowaychukbefore adoptiond0d17a0
line 571why, one step back571 res.charset = 'ISO-8859-1';Added .charset + res.send() testTj Holowaychukbefore adoption820b43c
line 572why, one step back572 res.send('<p>hey</p>');added charset test with res.render()Tj Holowaychukbefore adoptionbac62df
lines 573–576why, one step back573 });574575 assert.response(app,576 { url: '/' },charset tests using ISO-8859-1Tj Holowaychukbefore adoptiond0d17a0
line 577why, one step back577 { headers: { 'Content-Type': 'text/html; charset=ISO-8859-1' }});Added res.local(name[, val]) docsTj Holowaychukbefore adoption5ac0c6d
lines 578–579why, one step back578 }579};