Skip to content

Commit

Permalink
Fix off-by-one error in range requests
Browse files Browse the repository at this point in the history
Summary:
facebook/react-native#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: facebook/react-native#8219
Closes facebook/react-native#9254

Differential Revision: D3680070

fbshipit-source-id: 3f2a18ba9f35b45b340f4a1046bc099b8444eb7d
  • Loading branch information
nikki93 authored and Facebook Github Bot 8 committed Aug 6, 2016
1 parent bc9c3fc commit 0b9ca22
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion react-packager/src/Server/__tests__/Server-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
});

Expand Down
2 changes: 1 addition & 1 deletion react-packager/src/Server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0b9ca22

Please sign in to comment.