question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`request.clone()` doesn't preserve the original request

See original GitHub issue

The 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:closed
  • Created 7 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
scarlaccommented, Jun 3, 2016

@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.

0reactions
mislavcommented, May 27, 2016

@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.)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found