1
0
Fork 0

Request shouldn't set content-type header to "undefined"

Fixes #1776.
This commit is contained in:
Alan Plum 2016-03-09 13:04:34 +01:00
parent 13774aadb3
commit 33bf19874e
2 changed files with 9 additions and 4 deletions

View File

@ -80,6 +80,7 @@ function RequestSuite () {
expect(Number(res.headers['content-length'])).to.equal(res.rawBody.length);
var obj = JSON.parse(res.body);
expect(obj.path).to.equal(path);
expect(obj.headers).not.to.have.property('content-type');
},
////////////////////////////////////////////////////////////////////////////////

View File

@ -1,4 +1,4 @@
/*jshint globalstrict: true, sub: true */
/*jshint sub: true */
/*global exports: true */
'use strict';
@ -131,7 +131,11 @@ function request(req) {
}
}
let headers = {'content-type': contentType};
const headers = {};
if (contentType) {
headers['content-type'] = contentType;
}
if (req.headers) {
Object.keys(req.headers).forEach(function (name) {
@ -140,7 +144,7 @@ function request(req) {
}
if (req.auth) {
headers['authorization'] = (
headers['authorization'] = (//eslint-disable-line dot-notation
req.auth.bearer ?
'Bearer ' + req.auth.bearer :
'Basic ' + new Buffer(
@ -189,4 +193,4 @@ exports.Response = Response;
};
});
module.exports = exports;
module.exports = exports;