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

Function http_patch

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

Source from the content-addressed store, hash-verified

262}
263
264fn http_patch<'gc>(
265 ctx: &mut crate::vm::State<'gc>,
266 args: Vec<Value<'gc>>,
267) -> Result<Value<'gc>, VmError> {
268 if args.len() < 2 {
269 return Err(VmError::RuntimeError(
270 "URL and body required for PATCH request".into(),
271 ));
272 }
273
274 let url = args[0].as_string()?.to_string();
275 let body = args[1].as_string()?.to_string();
276 let headers = if args.len() > 2 {
277 if let Value::Object(obj) = args[2] {
278 obj.borrow().fields.clone()
279 } else {
280 return Err(VmError::RuntimeError("Headers must be an object".into()));
281 }
282 } else {
283 HashMap::default()
284 };
285
286 let headers_map = parse_headers(headers);
287
288 let result = Handle::current().block_on(async {
289 let response = make_request(reqwest::Method::PATCH, &url, headers_map, Some(body))
290 .await
291 .map_err(|e| VmError::RuntimeError(format!("HTTP request failed: {}", e)))?;
292
293 response_to_object(ctx.get_context(), response).await
294 })?;
295
296 Ok(result)
297}
298
299fn http_head<'gc>(
300 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
lenMethod · 0.80
as_stringMethod · 0.80
get_contextMethod · 0.80
cloneMethod · 0.45
borrowMethod · 0.45

Tested by

no test coverage detected