Remove incorrect set of bodyUsed flag when cloning a request #440
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.
This removes setting bodyUsed to true when you clone a request.
In order to use a request multiple times you need to clone a request, which lets you get a copy of the request while leaving the original request as is, as long as you didn't read the request body beforehand.
In Chrome implementation for example cloning a request does not change the bodyUsed property to true, however in this polyfill it does.
This prevents you from cloning a request and passing on the original request as passing it causes the Already Read exception even though the body was not read directly from that request (by the end user).
Polyfill scenario:
https://runkit.com/58308876f439290014bb0025/5830907cf836f700146fa4f7
Chrome Implementation scenario: (open the browser console to see the output)
https://plnkr.co/edit/OVK9RREqhMm3WcgPtxOf?p=preview
Sorry for not having a single place for both scenarios. I could not find a snippet service that allows me to bring the package from npm.
TL;DR
bodyUsed should not be set to true when cloning a request on the original request