From 01e3992d018166c00fd067cd2f768f44345a7ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CSourabh21=E2=80=9D?= <“Sourabhrodagi707@gmail.com”> Date: Sat, 21 Mar 2026 10:55:47 -0500 Subject: [PATCH] fix: send null body for DELETE requests when no body is provided Http.delete failed when called without a body/json argument because the default body was set to "" (empty string). The request library sent a Content-Length: 0 header, causing many REST APIs to reject the request with 400/411 errors. Fix: change the default body fallback from "" to null so that no body is sent when neither body nor json is explicitly provided. Adds two DELETE tests: - delete without a body succeeds - delete with a json body sends the payload correctly Closes #18 --- .../FunctionNodes/HttpDriver/HttpNode.js | 2 +- .../FunctionNodes/HttpDriver/test/http.js | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Nodes/FunctionNodes/HttpDriver/HttpNode.js b/src/Nodes/FunctionNodes/HttpDriver/HttpNode.js index bb01b97..cc8976a 100644 --- a/src/Nodes/FunctionNodes/HttpDriver/HttpNode.js +++ b/src/Nodes/FunctionNodes/HttpDriver/HttpNode.js @@ -101,7 +101,7 @@ class HttpNode { const params = self.queryParameters, url = self.urlWithParameters, - body = (operation === 'get') ? (null) : (self.args['body'] || ""), + body = (operation === 'get') ? (null) : (self.args['body'] || null), form = (operation === 'get') ? (null) : (self.args['form'] || null), json = (operation === 'get') ? (null) : (self.args['json'] || null), headers = { ...ops.Http['headers'], ...self.args['headers'] } || {}, diff --git a/src/Nodes/FunctionNodes/HttpDriver/test/http.js b/src/Nodes/FunctionNodes/HttpDriver/test/http.js index 61dc534..2822f72 100644 --- a/src/Nodes/FunctionNodes/HttpDriver/test/http.js +++ b/src/Nodes/FunctionNodes/HttpDriver/test/http.js @@ -66,4 +66,28 @@ module.exports = () => { assert.equal(res.url, "https://httpbin.org/post"); }).timeout(10000); }); + + describe('delete request', () => { + it('should perform delete request without a body', async () => { + let n = new HttpNode('Http.delete', [], { + url: "https://httpbin.org/delete" + }); + + let res = await n.eval({}, {}); + assert.equal(res.url, "https://httpbin.org/delete"); + }).timeout(10000); + + it('should perform delete request with a json body', async () => { + let n = new HttpNode('Http.delete', [], { + url: "https://httpbin.org/delete", + json: { + id: 42 + } + }); + + let res = await n.eval({}, {}); + assert.equal(res.json.id, 42); + assert.equal(res.url, "https://httpbin.org/delete"); + }).timeout(10000); + }); }; \ No newline at end of file