From 53222f0ddae6e03b47c6a0ddfab5f6be125312a4 Mon Sep 17 00:00:00 2001 From: James Ide Date: Fri, 24 Jul 2015 18:31:41 -0700 Subject: [PATCH] [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 --- .../react-packager/src/Server/__tests__/Server-test.js | 1 + packager/react-packager/src/Server/index.js | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packager/react-packager/src/Server/__tests__/Server-test.js b/packager/react-packager/src/Server/__tests__/Server-test.js index 32c9060a4..7d399cb2a 100644 --- a/packager/react-packager/src/Server/__tests__/Server-test.js +++ b/packager/react-packager/src/Server/__tests__/Server-test.js @@ -39,6 +39,7 @@ describe('processRequest', function() { requestHandler( { url: requrl }, { + setHeader: jest.genMockFunction(), end: function(res) { resolve(res); } diff --git a/packager/react-packager/src/Server/index.js b/packager/react-packager/src/Server/index.js index 1d2140ef5..a4ee53ef6 100644 --- a/packager/react-packager/src/Server/index.js +++ b/packager/react-packager/src/Server/index.js @@ -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); } },