Permalink
Browse files

Fix off-by-one error in range requests

Summary:
#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: #8219
Closes #9254

Differential Revision: D3680070

fbshipit-source-id: 3f2a18ba9f35b45b340f4a1046bc099b8444eb7d
  • Loading branch information...
1 parent bdf5adc commit a2417065b19f374da168a16afe4d7251bca1661a @nikki93 nikki93 committed with Facebook Github Bot 8 Aug 6, 2016
@@ -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));
});
});
@@ -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;

0 comments on commit a241706

Please sign in to comment.