Skip to content

Commit

Permalink
deps: send@0.14.0
Browse files Browse the repository at this point in the history
closes #66
  • Loading branch information
dougwilson committed Jun 7, 2016
1 parent 6e04944 commit b36f161
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 2 deletions.
16 changes: 16 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
unreleased
==========

* deps: send@0.14.0
- Add `acceptRanges` option
- Add `cacheControl` option
- Attempt to combine multiple ranges into single range
- Correctly inherit from `Stream` class
- Fix `Content-Range` header in 416 responses when using `start`/`end` options
- Fix `Content-Range` header missing from default 416 responses
- Ignore non-byte `Range` headers
- deps: http-errors@~1.5.0
- deps: range-parser@~1.2.0
- deps: statuses@~1.3.0
- perf: remove argument reassignment

1.10.3 / 2016-05-30
===================

Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ to the next middleware, allowing for stacking and fall-backs.

#### Options

##### acceptRanges

Enable or disable accepting ranged requests, defaults to true.
Disabling this will not send `Accept-Ranges` and ignore the contents
of the `Range` request header.

##### cacheControl

Enable or disable setting `Cache-Control` response header, defaults to
true. Disabling this will ignore the `maxAge` option.

##### dotfiles

Set how "dotfiles" are treated when encountered. A dotfile is a file
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dependencies": {
"escape-html": "~1.0.3",
"parseurl": "~1.3.1",
"send": "0.13.2"
"send": "0.14.0"
},
"devDependencies": {
"eslint": "2.11.1",
Expand Down
67 changes: 66 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,71 @@ describe('serveStatic()', function () {
})
})

describe('acceptRanges', function () {
describe('when false', function () {
it('should not include Accept-Ranges', function (done) {
request(createServer(fixtures, {'acceptRanges': false}))
.get('/nums')
.expect(shouldNotHaveHeader('Accept-Ranges'))
.expect(200, '123456789', done)
})

it('should ignore Rage request header', function (done) {
request(createServer(fixtures, {'acceptRanges': false}))
.get('/nums')
.set('Range', 'bytes=0-3')
.expect(shouldNotHaveHeader('Accept-Ranges'))
.expect(shouldNotHaveHeader('Content-Range'))
.expect(200, '123456789', done)
})
})

describe('when true', function () {
it('should include Accept-Ranges', function (done) {
request(createServer(fixtures, {'acceptRanges': true}))
.get('/nums')
.expect('Accept-Ranges', 'bytes')
.expect(200, '123456789', done)
})

it('should obey Rage request header', function (done) {
request(createServer(fixtures, {'acceptRanges': true}))
.get('/nums')
.set('Range', 'bytes=0-3')
.expect('Accept-Ranges', 'bytes')
.expect('Content-Range', 'bytes 0-3/9')
.expect(206, '1234', done)
})
})
})

describe('cacheControl', function () {
describe('when false', function () {
it('should not include Cache-Control', function (done) {
request(createServer(fixtures, {'cacheControl': false}))
.get('/nums')
.expect(shouldNotHaveHeader('Cache-Control'))
.expect(200, '123456789', done)
})

it('should ignore maxAge', function (done) {
request(createServer(fixtures, {'cacheControl': false, 'maxAge': 12000}))
.get('/nums')
.expect(shouldNotHaveHeader('Cache-Control'))
.expect(200, '123456789', done)
})
})

describe('when true', function () {
it('should include Cache-Control', function (done) {
request(createServer(fixtures, {'cacheControl': true}))
.get('/nums')
.expect('Cache-Control', 'public, max-age=0')
.expect(200, '123456789', done)
})
})
})

describe('extensions', function () {
it('should be not be enabled by default', function (done) {
var server = createServer(fixtures)
Expand Down Expand Up @@ -478,7 +543,7 @@ describe('serveStatic()', function () {
})
})

describe('Range', function () {
describe('when request has "Range" header', function () {
var server
before(function () {
server = createServer()
Expand Down

0 comments on commit b36f161

Please sign in to comment.