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
This commit is contained in:
Nikhilesh Sigatapu 2016-08-06 03:22:29 -07:00 committed by Facebook Github Bot 8
parent bc9c3fc902
commit 0b9ca22fb2
2 changed files with 2 additions and 2 deletions

View File

@ -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));
});
});

View File

@ -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;