MCPcopy Create free account
hub / github.com/awslabs/llrt / bytes

Method bytes

modules/llrt_fetch/src/request.rs:438–451  ·  view source on GitHub ↗
(&self, ctx: Ctx<'js>)

Source from the content-addressed store, hash-verified

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())?;

Callers 4

is_http_header_nameFunction · 0.45
has_bare_cr_lfFunction · 0.45

Calls 5

reject_with_errorFunction · 0.85
resolve_body_takenFunction · 0.85
take_body_syncMethod · 0.80
cloneMethod · 0.45
into_valueMethod · 0.45

Tested by

no test coverage detected