From 0b9ca22fb26449479838e49f78c03dfbef9312b6 Mon Sep 17 00:00:00 2001 From: Nikhilesh Sigatapu Date: Sat, 6 Aug 2016 03:22:29 -0700 Subject: [PATCH] Fix off-by-one error in range requests Summary: https://github.com/facebook/react-native/pull/8219 adds range requests to the asset server, but there was an off-by-one-error that made responses end prematurely. This made (for example) react-native-video not work for video assets. This change fixes the off-by-one error and react-native-video works with assets. **Test plan (required)** Try the test in the original pull request for range requests: https://github.com/facebook/react-native/pull/8219 Closes https://github.com/facebook/react-native/pull/9254 Differential Revision: D3680070 fbshipit-source-id: 3f2a18ba9f35b45b340f4a1046bc099b8444eb7d --- react-packager/src/Server/__tests__/Server-test.js | 2 +- react-packager/src/Server/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/react-packager/src/Server/__tests__/Server-test.js b/react-packager/src/Server/__tests__/Server-test.js index 6d841d91..640da7eb 100644 --- a/react-packager/src/Server/__tests__/Server-test.js +++ b/react-packager/src/Server/__tests__/Server-test.js @@ -362,7 +362,7 @@ describe('processRequest', () => { server.processRequest(req, res); jest.runAllTimers(); expect(AssetServer.prototype.get).toBeCalledWith('imgs/a.png', 'ios'); - expect(res.end).toBeCalledWith(mockData.slice(0, 3)); + expect(res.end).toBeCalledWith(mockData.slice(0, 4)); }); }); diff --git a/react-packager/src/Server/index.js b/react-packager/src/Server/index.js index 751c3891..87db0787 100644 --- a/react-packager/src/Server/index.js +++ b/react-packager/src/Server/index.js @@ -407,7 +407,7 @@ class Server { 'Content-Type': mime.lookup(path.basename(assetPath[1])) }); - return data.slice(dataStart, dataEnd); + return data.slice(dataStart, dataEnd + 1); } return data;