`request.clone()` doesn't preserve the original request
See original GitHub issueThe purpose of the clone()
method is to allow reuse of the (normally single-use) Body
of the request. Unfortunately, the implementation in this polyfill doesn’t allow that.
To illustrate the problem, this example code will fail:
var r1 = new Request('http://somewhere.com', { method: 'POST', body: 'test' });
var r2 = r1.clone();
r1.text(); // --> fails - but should succeed
r2.text(); // --> succeeds
The clone()
method in this polyfill just delegates to the constructor, but the constructor is supposed to consume the stream of the original request (which it does), and the clone()
method is supposed to leave it untouched.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
c# - How to clone a HttpRequestMessage when the original ...
One note: this answer regards HttpResponseMessage cloning. The question was about cloning the request, not the response. The approach is fairly similar. –...
Read more >Request.clone() - Web APIs | MDN
The clone() method of the Request interface creates a copy of the current Request object.
Read more >Instance clone FAQs - Frequently Asked Questions
How does the clone work? In response to a clone request, the ServiceNow platform performs the following tasks: Generates a file to preserve...
Read more >Request · Cloudflare Workers docs
The most common way you will encounter a Request object is as a ... to fetch() es made by a Worker that are...
Read more >HTTP header manipulation - Envoy Proxy
Envoy will always set the :scheme header while processing a request. ... for edge Envoys 1 which doesn't have a comparable vector for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mislav, Let me know if you need more changes to the PR for it to be acceptable. I’ll be happy to refine it further.
@scarlac Ah I see that you opened a pull request already. I didn’t see a cross-reference here because you referenced this issue number in PR title but not body. (Cross-references are only counted when they are in issue/PR body.)