-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add documentation for Request.prototype.clone()
- Loading branch information
1 parent
0e330b5
commit 9d12321
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
hide_title: false | ||
hide_table_of_contents: false | ||
pagination_next: null | ||
pagination_prev: null | ||
--- | ||
# Request.clone() | ||
|
||
The **`clone()`** method of the `Request` interface creates a copy of the current `Request` object. | ||
|
||
Like the underlying `ReadableStream.tee`` api, the `body` of a cloned `Response` | ||
will signal backpressure at the rate of the _faster_ consumer of the two bodies, | ||
and unread data is enqueued internally on the slower consumed `body` | ||
without any limit or backpressure. | ||
Beware when you construct a `Request` from a stream and then `clone` it. | ||
|
||
`clone()` throws a `TypeError` if the request body has already been used. In fact, the main reason `clone()` exists is to allow multiple uses of body objects (when they are one-use only.) | ||
|
||
If you intend to modify the request, you may prefer the `Request` constructor. | ||
|
||
## Syntax | ||
|
||
```js | ||
clone() | ||
``` | ||
|
||
### Parameters | ||
|
||
None. | ||
|
||
### Return value | ||
|
||
A `Request` object, which is an exact copy of the `Request` that `clone()` was called on. | ||
|