diff --git a/ghost/core/core/server/adapters/storage/LocalStorageBase.js b/ghost/core/core/server/adapters/storage/LocalStorageBase.js index 6a0e3372f801..274247fbfaf3 100644 --- a/ghost/core/core/server/adapters/storage/LocalStorageBase.js +++ b/ghost/core/core/server/adapters/storage/LocalStorageBase.js @@ -149,6 +149,10 @@ class LocalStorageBase extends StorageBase { return next(new errors.NoPermissionError({err: err})); } + if (err.name === 'RangeNotSatisfiableError') { + return next(new errors.RangeNotSatisfiableError({err})); + } + return next(new errors.InternalServerError({err: err})); } diff --git a/ghost/core/test/unit/server/adapters/storage/LocalBaseStorage.test.js b/ghost/core/test/unit/server/adapters/storage/LocalBaseStorage.test.js index dd0724ee247d..204878cf3f85 100644 --- a/ghost/core/test/unit/server/adapters/storage/LocalBaseStorage.test.js +++ b/ghost/core/test/unit/server/adapters/storage/LocalBaseStorage.test.js @@ -2,6 +2,27 @@ const should = require('should'); const LocalStorageBase = require('../../../../../core/server/adapters/storage/LocalStorageBase'); describe('Local Storage Base', function () { + describe('serve', function () { + it('returns a 416 RangeNotSatisfiableError if given an invalid range', function(done) { + const localStorageBase = new LocalStorageBase({ + storagePath: '/media-storage/path/', + staticFileURLPrefix: 'content/media', + siteUrl: 'http://example.com/blog/' + }); + + ??????????? + + req.headers = { + range: 'bytes=1000-999' + }; + + localStorageBase.serve()(req, res, () => { + // TODO: check this is a 416 RangeNotSatisfiableError + done(); + }); + }); + }); + describe('urlToPath', function () { it('returns path from url', function () { let localStorageBase = new LocalStorageBase({