Repository: couchdb-nmo
Updated Branches:
  refs/heads/master a449cbc7f -> 22ca5e0c2


Set content-type to application/json

Set content-type to application json for /cluster_setup requests


Project: http://git-wip-us.apache.org/repos/asf/couchdb-nmo/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-nmo/commit/22ca5e0c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-nmo/tree/22ca5e0c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-nmo/diff/22ca5e0c

Branch: refs/heads/master
Commit: 22ca5e0c22b839626e7f280724659c199e6b634f
Parents: a449cbc
Author: Garren Smith <[email protected]>
Authored: Wed Sep 23 15:17:36 2015 +0200
Committer: Garren Smith <[email protected]>
Committed: Wed Sep 23 15:17:36 2015 +0200

----------------------------------------------------------------------
 src/utils.js  | 10 +++++++++-
 test/utils.js | 20 ++++++++++++++++++--
 2 files changed, 27 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/22ca5e0c/src/utils.js
----------------------------------------------------------------------
diff --git a/src/utils.js b/src/utils.js
index 885dedb..a0ad1db 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -39,7 +39,15 @@ export function sendJsonToNode (url, json) {
     const cleanedUrl = removeUsernamePw(url);
     log.http('request', 'POST', cleanedUrl);
 
-    Wreck.post(url, {payload: JSON.stringify(json), json: true}, (err, res, 
body) => {
+    const opts = {
+      headers: {
+        'Content-Type': 'application/json'
+      },
+      payload: JSON.stringify(json),
+      json: true,
+    };
+
+    Wreck.post(url, opts, (err, res, body) => {
       if (err) {
         return reject(err);
       }

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/22ca5e0c/test/utils.js
----------------------------------------------------------------------
diff --git a/test/utils.js b/test/utils.js
index 8770e64..c0dfa9f 100644
--- a/test/utils.js
+++ b/test/utils.js
@@ -1,5 +1,6 @@
 import assert from 'assert';
 import http from 'http';
+import nock from 'nock';
 
 import Lab from 'lab';
 export const lab = Lab.script();
@@ -58,9 +59,7 @@ lab.experiment('utils: checkUrl', () => {
   });
 });
 
-
 lab.experiment('utils: send json to node', () => {
-
   let data = '', server;
 
   lab.before((done) => {
@@ -114,6 +113,23 @@ lab.experiment('utils: send json to node', () => {
         done();
       });
   });
+
+  lab.test('sets "Content-Type" as "application/json"', done => {
+    const url = 'http://content-type.test';
+    const body = {test: true};
+    nock(url,{
+      reqheaders: {
+        'content-type': 'application/json'
+      }
+    })
+    .post('/')
+    .reply(200);
+
+    utils.sendJsonToNode(url +'/', body)
+    .then(res => { done(); });
+  });
+
+
 });
 
 lab.experiment('utils: removeUsernamePw', () => {

Reply via email to