fix: send null body for DELETE requests when no body is provided#41
Open
sourabhgithubcode wants to merge 1 commit intoRapidAPI:masterfrom
Open
fix: send null body for DELETE requests when no body is provided#41sourabhgithubcode wants to merge 1 commit intoRapidAPI:masterfrom
sourabhgithubcode wants to merge 1 commit intoRapidAPI:masterfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #18
Http.deletefailed when called without abodyorjsonargument because the body defaulted to""(empty string). Therequestlibrary then sent aContent-Length: 0header, causing many REST APIs to reject DELETE requests with 400/411 errors.Root cause: The body fallback used
""instead ofnullfor all non-GET methods:When
bodyisnull, therequestlibrary sends no body and omitsContent-Length, which is the correct behavior for a bodyless DELETE.Changes
src/Nodes/FunctionNodes/HttpDriver/HttpNode.js— change default body fallback from""tonullsrc/Nodes/FunctionNodes/HttpDriver/test/http.js— add two DELETE tests:jsonbody correctly sends the payloadTest plan
npm test— all existing tests passhttpbin.org