Skip to content

Commit

Permalink
Test for symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
piranna committed Dec 9, 2015
1 parent 632cbe2 commit 1f0d536
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions test/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,27 @@ describe('send(file).pipe(res)', function(){
.expect(301, 'Redirecting to /pets/', done)
})

it("should 301 if it's a symbolic link", function(done){
var destination = 'name.txt'
var path2 = path.join(fixtures, 'symlink')

fs.symlink(destination, path2, function(error)
{
if(error && error.code !== 'EEXIST') return done(error)

request(app)
.get('/symlink')
.expect('Location', destination)
.expect(301, 'Redirecting to <a href="'+destination+'">'+destination+'</a>\n', function(error)
{
fs.unlink(path2, function(error2)
{
done(error || error2)
})
})
})
})

it('should not override content-type', function(done){
var app = http.createServer(function(req, res){
res.setHeader('Content-Type', 'application/x-custom')
Expand Down Expand Up @@ -410,14 +431,14 @@ describe('send(file).pipe(res)', function(){
.set('Range', 'bytes=0-4')
.expect(206, '12345', done);
})

it('should be inclusive', function(done){
request(app)
.get('/nums')
.set('Range', 'bytes=0-0')
.expect(206, '1', done);
})

it('should set Content-Range', function(done){
request(app)
.get('/nums')
Expand All @@ -432,7 +453,7 @@ describe('send(file).pipe(res)', function(){
.set('Range', 'bytes=-3')
.expect(206, '789', done);
})

it('should support n-', function(done){
request(app)
.get('/nums')
Expand Down Expand Up @@ -1063,7 +1084,7 @@ describe('send(file, options)', function(){
send(req, 'test/fixtures/name.txt', {maxAge: Infinity})
.pipe(res);
});

request(app)
.get('/name.txt')
.expect('Cache-Control', 'public, max-age=31536000', done)
Expand Down

0 comments on commit 1f0d536

Please sign in to comment.