Fun VM opcode snippet: HTTP GET via libcurl (OP_CURL_GET).
This snippet is included by vm.c and implements the OP_CURL_GET instruction. When FUN_WITH_CURL is enabled, it performs an HTTP GET request for the provided URL and pushes the response body as a string. If libcurl support is not built in, or an error occurs, an empty string is pushed instead.
Stack behavior:
- Pops: url:string (any value is converted via value_to_string_alloc)
- Pushes: body:string ("" on error or when CURL is disabled)
Converts the top stack value to a URL string, issues a GET request using libcurl, and pushes the response body as a string. When compiled without FUN_WITH_CURL, the opcode becomes a no-op that consumes one value and pushes an empty string.
Error handling:
- If URL conversion fails or CURL initialization/performance fails, the opcode pushes an empty string.
- Follows HTTP redirects (CURLOPT_FOLLOWLOCATION = 1L).
Notes:
- Uses FunCurlBuf and fun_curl_write_cb from the curl extension helpers.
- Memory allocated for temporary strings and buffers is freed before exit.
Definition in file get.c.