Skip to content

Commit

Permalink
[Packager] Include Content-Type headers with bundle and source maps
Browse files Browse the repository at this point in the history
Summary:
The packager did not send back the Content-Type headers. Adding these.

Closes facebook/react-native#2029
Github Author: James Ide <[email protected]>
  • Loading branch information
ide committed Jul 25, 2015
1 parent 4b7f9c6 commit 03b4050
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions react-packager/src/Server/__tests__/Server-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe('processRequest', function() {
requestHandler(
{ url: requrl },
{
setHeader: jest.genMockFunction(),
end: function(res) {
resolve(res);
}
Expand Down
10 changes: 7 additions & 3 deletions react-packager/src/Server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,17 @@ Server.prototype.processRequest = function(req, res, next) {
building.then(
function(p) {
if (requestType === 'bundle') {
res.end(p.getSource({
var bundleSource = p.getSource({
inlineSourceMap: options.inlineSourceMap,
minify: options.minify,
}));
});
res.setHeader('Content-Type', 'application/javascript');
res.end(bundleSource);
Activity.endEvent(startReqEventId);
} else if (requestType === 'map') {
res.end(JSON.stringify(p.getSourceMap()));
var sourceMap = JSON.stringify(p.getSourceMap());
res.setHeader('Content-Type', 'application/json');
res.end(sourceMap);
Activity.endEvent(startReqEventId);
}
},
Expand Down

0 comments on commit 03b4050

Please sign in to comment.