[Packager] Include Content-Type headers with bundle and source maps

Summary:
The packager did not send back the Content-Type headers. Adding these.

Closes https://github.com/facebook/react-native/pull/2029
Github Author: James Ide <ide@jameside.com>
This commit is contained in:
James Ide 2015-07-24 18:31:41 -07:00
parent 4b7f9c60c4
commit 03b4050c6e
2 changed files with 8 additions and 3 deletions

View File

@ -39,6 +39,7 @@ describe('processRequest', function() {
requestHandler( requestHandler(
{ url: requrl }, { url: requrl },
{ {
setHeader: jest.genMockFunction(),
end: function(res) { end: function(res) {
resolve(res); resolve(res);
} }

View File

@ -358,13 +358,17 @@ Server.prototype.processRequest = function(req, res, next) {
building.then( building.then(
function(p) { function(p) {
if (requestType === 'bundle') { if (requestType === 'bundle') {
res.end(p.getSource({ var bundleSource = p.getSource({
inlineSourceMap: options.inlineSourceMap, inlineSourceMap: options.inlineSourceMap,
minify: options.minify, minify: options.minify,
})); });
res.setHeader('Content-Type', 'application/javascript');
res.end(bundleSource);
Activity.endEvent(startReqEventId); Activity.endEvent(startReqEventId);
} else if (requestType === 'map') { } 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); Activity.endEvent(startReqEventId);
} }
}, },