script: Implement the Bytes() method on Request and Response (#35250)

* Implement the Bytes() method on Request and Response

Signed-off-by: Shane Handley <shanehandley@fastmail.com>

* avoid unsafe code during buffer creation

Signed-off-by: Shane Handley <shanehandley@fastmail.com>

---------

Signed-off-by: Shane Handley <shanehandley@fastmail.com>
This commit is contained in:
shanehandley 2025-02-02 18:49:48 +11:00 committed by GitHub
parent f364b3f6ea
commit 938baf6bf3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 33 additions and 149 deletions

View file

@ -386,6 +386,11 @@ impl ResponseMethods<crate::DomTypeHolder> for Response {
fn ArrayBuffer(&self, can_gc: CanGc) -> Rc<Promise> {
consume_body(self, BodyType::ArrayBuffer, can_gc)
}
/// <https://fetch.spec.whatwg.org/#dom-body-bytes>
fn Bytes(&self, can_gc: CanGc) -> std::rc::Rc<Promise> {
consume_body(self, BodyType::Bytes, can_gc)
}
}
fn serialize_without_fragment(url: &ServoUrl) -> &str {