Auto merge of #29640 - CYBAI:fix-response-empty-init, r=mrobinson

Reset to in-memory stream with empty byte sequence for None init body

Because the response body stream is initialized with FetchResponse, it cannot be processed with in-memory empty sequence. Thus, instead of using the FetchResponse stream, we'll reset it to Memory body stream with empty byte sequence if there's no init body.

With this PR, we can fix the TIMEOUT in `/fetch/content-type/response.window.html` so I think it should fix #22304.

---

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #22304
- [x] There are tests for these changes
This commit is contained in:
bors-servo 2023-04-28 13:57:03 +02:00 committed by GitHub
commit 8a779b84d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 109 additions and 984 deletions

View file

@ -144,6 +144,11 @@ impl Response {
)?;
}
};
} else {
// Reset FetchResponse to an in-memory stream with empty byte sequence here for
// no-init-body case
let stream = ReadableStream::new_from_bytes(&global, Vec::with_capacity(0));
r.body_stream.set(Some(&*stream));
}
Ok(r)