Removal of body and some headers on redirects #2559
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.
PR Checklist:
npm test
locally and all tests are passing.PR Description
As pointed out in issue #2464 some headers, body and _form are being remove on redirects.
Added options followOriginalBody (boolean) and followOriginalBodyForCodes (list) such that if the response status is in followOriginalBodyForCodes ([401, 307] by default to maintain current behavior) or followOriginalBody is true (false by default to maintain current behavior), then host, content-type and content-length headers, body and _form are not removed.
Added the debug information of the headers, body and _form on redirection as the debug info in request.init(options) contains the options, which are not defined in case of redirections.
Also added some tests to check that in case of redirection the above mentioned headers are being removed when the response status is not in followOriginalBodyForCodes and followOriginalBody is false, and not being removed otherwise. The removal or not of the body and _form should also be tested but couldn't find them in the request (indications on how to test them are welcome and appreciated).
Please find below the debug output, including the empty "REQUEST" and the added "REQUEST redirect with headers", "REQUEST redirect with body" and "REQUEST redirect with _form".