MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / http_delete

Function http_delete

aiscript-vm/src/stdlib/http.rs:231–262  ·  view source on GitHub ↗
(
    ctx: &mut crate::vm::State<'gc>,
    args: Vec<Value<'gc>>,
)

Source from the content-addressed store, hash-verified

229}
230
231fn http_delete<'gc>(
232 ctx: &mut crate::vm::State<'gc>,
233 args: Vec<Value<'gc>>,
234) -> Result<Value<'gc>, VmError> {
235 if args.is_empty() {
236 return Err(VmError::RuntimeError(
237 "URL required for DELETE request".into(),
238 ));
239 }
240
241 let url = args[0].as_string()?.to_string();
242 let headers_map = if args.len() > 1 {
243 if let Value::Object(obj) = args[1] {
244 let borrowed = obj.borrow();
245 parse_headers(borrowed.fields.clone())
246 } else {
247 return Err(VmError::RuntimeError("Headers must be an object".into()));
248 }
249 } else {
250 HeaderMap::new()
251 };
252
253 let result = Handle::current().block_on(async {
254 let response = make_request(reqwest::Method::DELETE, &url, headers_map, None)
255 .await
256 .map_err(|e| VmError::RuntimeError(format!("HTTP request failed: {}", e)))?;
257
258 response_to_object(ctx.get_context(), response).await
259 })?;
260
261 Ok(result)
262}
263
264fn http_patch<'gc>(
265 ctx: &mut crate::vm::State<'gc>,

Callers

nothing calls this directly

Calls 9

RuntimeErrorClass · 0.85
parse_headersFunction · 0.85
make_requestFunction · 0.85
response_to_objectFunction · 0.85
as_stringMethod · 0.80
lenMethod · 0.80
get_contextMethod · 0.80
borrowMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected