From 075ca6a3a580896da593e7f354e3676f15bdf66c Mon Sep 17 00:00:00 2001 From: Alan Plum Date: Wed, 9 Mar 2016 13:10:41 +0100 Subject: [PATCH] Request shouldn't set content-type header to "undefined" Fixes #1776. --- js/client/tests/shell/shell-request.js | 1 + js/common/modules/@arangodb/request.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/js/client/tests/shell/shell-request.js b/js/client/tests/shell/shell-request.js index 48a1d0f47f..e29685e637 100644 --- a/js/client/tests/shell/shell-request.js +++ b/js/client/tests/shell/shell-request.js @@ -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'); }, //////////////////////////////////////////////////////////////////////////////// diff --git a/js/common/modules/@arangodb/request.js b/js/common/modules/@arangodb/request.js index 185ae6b702..de473a2142 100644 --- a/js/common/modules/@arangodb/request.js +++ b/js/common/modules/@arangodb/request.js @@ -1,4 +1,4 @@ -/*jshint globalstrict: true, sub: true */ +/*jshint sub: true */ /*global exports: true */ 'use strict'; @@ -130,7 +130,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) { @@ -139,7 +143,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( @@ -188,4 +192,4 @@ exports.Response = Response; }; }); -module.exports = exports; \ No newline at end of file +module.exports = exports;