Skip to content

fix: send null body for DELETE requests when no body is provided#41

Open
sourabhgithubcode wants to merge 1 commit intoRapidAPI:masterfrom
sourabhgithubcode:fix/http-delete-no-body
Open

fix: send null body for DELETE requests when no body is provided#41
sourabhgithubcode wants to merge 1 commit intoRapidAPI:masterfrom
sourabhgithubcode:fix/http-delete-no-body

Conversation

@sourabhgithubcode
Copy link

Summary

Fixes #18

Http.delete failed when called without a body or json argument because the body defaulted to "" (empty string). The request library then sent a Content-Length: 0 header, causing many REST APIs to reject DELETE requests with 400/411 errors.

Root cause: The body fallback used "" instead of null for all non-GET methods:

// before
body = (operation === 'get') ? (null) : (self.args['body'] || ""),

// after
body = (operation === 'get') ? (null) : (self.args['body'] || null),

When body is null, the request library sends no body and omits Content-Length, which is the correct behavior for a bodyless DELETE.

Changes

  • src/Nodes/FunctionNodes/HttpDriver/HttpNode.js — change default body fallback from "" to null
  • src/Nodes/FunctionNodes/HttpDriver/test/http.js — add two DELETE tests:

Test plan

  • npm test — all existing tests pass
  • New DELETE tests pass against httpbin.org

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 RapidAPI#18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Http.delete fails is body / json parameter is not passed

1 participant