bool bodyAll(JSContext *cx, CallArgs args, HandleObject self) {
  // TODO: mark body as consumed when operating on stream, too.
  if (body_used(self)) {
    JS_ReportErrorASCII(cx, "Body has already been consumed");
    return ReturnPromiseRejectedWithPendingError(cx, args);
  }

  RootedObject bodyAll_promise(cx, JS::NewPromiseObject(cx, nullptr));
  if (!bodyAll_promise) {
    return ReturnPromiseRejectedWithPendingError(cx, args);
  }
  JS::SetReservedSlot(self, Slots::BodyAllPromise, ObjectValue(*bodyAll_promise));

  // If the Request/Response doesn't have a body, empty default results need to
  // be returned.
  if (!has_body(self)) {
    UniqueChars chars;
    if (!parse_body<result_type>(cx, self, std::move(chars), 0)) {
      return ReturnPromiseRejectedWithPendingError(cx, args);
    }

    args.rval().setObject(*bodyAll_promise);
    return true;
  }

  if (!mark_body_used(cx, self)) {
    return ReturnPromiseRejectedWithPendingError(cx, args);
  }

  RootedValue body_parser(cx, JS::PrivateValue((void *)parse_body<result_type>));

  // If the body is a ReadableStream that's not backed by a BodyHandle,
  // we need to manually read all chunks from the stream.
  // TODO(performance): ensure that we're properly shortcutting reads from TransformStream
  // readables.
  // https://github.com/fastly/js-compute-runtime/issues/218
  RootedObject stream(cx, body_stream(self));
  if (stream && !builtins::NativeStreamSource::stream_is_body(cx, stream)) {
    if (!consume_content_stream_for_bodyAll(cx, self, stream, body_parser)) {
      return ReturnPromiseRejectedWithPendingError(cx, args);
    }
  } else {
    if (!enqueue_internal_method<consume_body_handle_for_bodyAll>(cx, self, body_parser)) {
      return ReturnPromiseRejectedWithPendingError(cx, args);
    }
  }

  args.rval().setObject(*bodyAll_promise);
  return true;
}
bool bodyAll(JSContext *cx, CallArgs args, HandleObject self) {
   
  if (body_used(self)) {
    JS_ReportErrorASCII(cx, "Body has already been consumed");
    return ReturnPromiseRejectedWithPendingError(cx, args);
  }

  RootedObject bodyAll_promise(cx, JS::NewPromiseObject(cx, nullptr));
  if (!bodyAll_promise) {
    return ReturnPromiseRejectedWithPendingError(cx, args);
  }
  JS::SetReservedSlot(self, Slots::BodyAllPromise, ObjectValue(*bodyAll_promise));

   
   
  if (!has_body(self)) {
    UniqueChars chars;
    if (!parse_body<result_type>(cx, self, std::move(chars), 0)) {
      return ReturnPromiseRejectedWithPendingError(cx, args);
    }

    args.rval().setObject(*bodyAll_promise);
    return true;
  }

  if (!mark_body_used(cx, self)) {
    return ReturnPromiseRejectedWithPendingError(cx, args);
  }

  RootedValue body_parser(cx, JS::PrivateValue((void *)parse_body<result_type>));

   
   
   
   
   
  RootedObject stream(cx, body_stream(self));
  if (stream && !builtins::NativeStreamSource::stream_is_body(cx, stream)) {
    if (!consume_content_stream_for_bodyAll(cx, self, stream, body_parser)) {
      return ReturnPromiseRejectedWithPendingError(cx, args);
    }
  } else {
    if (!enqueue_internal_method<consume_body_handle_for_bodyAll>(cx, self, body_parser)) {
      return ReturnPromiseRejectedWithPendingError(cx, args);
    }
  }

  args.rval().setObject(*bodyAll_promise);
  return true;
}