(&self, ctx: Ctx<'js>)
| 436 | } |
| 437 | |
| 438 | fn bytes(&self, ctx: Ctx<'js>) -> Result<Promise<'js>> { |
| 439 | let body = match self.take_body_sync(&ctx) { |
| 440 | Ok(b) => b, |
| 441 | Err(e) => return reject_with_error(&ctx, e), |
| 442 | }; |
| 443 | let ctx_clone = ctx.clone(); |
| 444 | Promise::wrap_future(&ctx, async move { |
| 445 | let bytes_opt = resolve_body_taken(&ctx_clone, body).await?; |
| 446 | if let Some(bytes) = bytes_opt { |
| 447 | return TypedArray::new(ctx_clone, bytes).map(|m| m.into_value()); |
| 448 | } |
| 449 | TypedArray::new(ctx_clone, Vec::<u8>::new()).map(|m| m.into_value()) |
| 450 | }) |
| 451 | } |
| 452 | |
| 453 | fn blob(&self, ctx: Ctx<'js>) -> Result<Promise<'js>> { |
| 454 | let mime_type = self.get_header_value(&ctx, CONTENT_TYPE.as_str())?; |
no test coverage detected