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.
This commit is contained in:
cybai 2023-04-17 17:07:17 +09:00
parent 7eca93bb7a
commit 7c9c786053
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)