-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Response.clone() does not properly clone the underlying streams #36503
Copy link
Copy link
Closed
Description
servo/components/script/dom/response.rs
Line 344 in d5284df
| if let Some(stream) = self.body_stream.get().clone() { |
teeing the body stream. https://fetch.spec.whatwg.org/#concept-body-clone I attempted to make this change
diff --git a/components/script/dom/response.rs b/components/script/dom/response.rs
index 283b7d615a..a76076a780 100644
--- a/components/script/dom/response.rs
+++ b/components/script/dom/response.rs
@@ -341,8 +341,13 @@ impl ResponseMethods<crate::DomTypeHolder> for Response {
.borrow_mut()
.clone_from(&self.url_list.borrow());
- if let Some(stream) = self.body_stream.get().clone() {
- new_response.body_stream.set(Some(&*stream));
+ // 3. If response’s body is non-null, then set newResponse’s body to the result of cloning response’s body.
+ if let Some(stream) = self.body_stream.get() {
+ // Let out1, out2 be the result of teeing body’s stream.
+ let teed_streams = stream.tee(true, can_gc)?;
+
+ self.body_stream.set(Some(&*teed_streams[0]));
+ new_response.body_stream.set(Some(&*teed_streams[1]));
}and this resulted in a new pass in /fetch/api/response/response-clone.any.html but also caused most of the tests to timeout. I was not able to figure out why this causes a hang.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels