From 308cb33e9bcd981123a6a0450da40f64db6de917 Mon Sep 17 00:00:00 2001 From: Sander Kruger Date: Sat, 19 Feb 2022 13:16:22 +0100 Subject: [PATCH] Add option to force content-type --- lib/client.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/client.js b/lib/client.js index ebd9cf1..9a9a445 100644 --- a/lib/client.js +++ b/lib/client.js @@ -14,6 +14,7 @@ function Client(options){ this.agent = (this.protocol==='https')? https : http; this.method = options.method || "POST"; this.path = options.path || '/'; + this.contentType = options.contentType || null; if(options && options.hasOwnProperty('user') && (options.hasOwnProperty('password') || options.hasOwnProperty('pass'))){ this.authNeeded=true; this.authData = options.user; @@ -67,7 +68,7 @@ Client.prototype.call = function(options, callback, id){ port: this.port, path: this.path, headers:{ - 'content-type':(this.method=='POST') ? 'application/x-www-form-urlencoded' :'application/json', + 'content-type':(this.contentType!==null) ? this.contentType : (this.method=='POST') ? 'application/x-www-form-urlencoded' :'application/json', 'content-length':(requestData).length } };