Skip to content

Commit

Permalink
Merge pull request #1778 from cjihrig/1777
Browse files Browse the repository at this point in the history
Do not create a duplicate Content-Type header on proxy passthrough
  • Loading branch information
Eran Hammer committed Jul 14, 2014
2 parents b4a3e13 + f63c97d commit eacd8f6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ exports.handler = function (route, options) {

var contentType = req.headers['content-type'];
if (contentType) {
options.headers['Content-Type'] = contentType;
options.headers['content-type'] = contentType;
}

// Send request
Expand Down
19 changes: 19 additions & 0 deletions test/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1292,5 +1292,24 @@ describe('Proxy', function () {
});
});
});

it('does not send multiple Content-Type headers on passthrough', function (done) {

var server = new Hapi.Server();
var requestFn = Nipple.request;

Nipple.request = function (method, url, options, cb) {

Nipple.request = requestFn;
expect(options.headers['content-type']).to.equal('application/json');
expect(options.headers['Content-Type']).to.not.exist;
cb(new Error('placeholder'));
};
server.route({ method: 'GET', path: '/test', handler: { proxy: { uri: 'http://localhost', passThrough: true } } });
server.inject({ method: 'GET', url: '/test', headers: { 'Content-Type': 'application/json' } }, function (res) {

done();
});
});
});

0 comments on commit eacd8f6

Please sign in to comment.