Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
get.c File Reference

Fun VM opcode snippet: HTTP GET via libcurl (OP_CURL_GET). More...

Go to the source code of this file.

Functions

 free_value (v)
 push_value (vm, make_string(""))

Variables

case OP_CURL_GET
 break

Detailed Description

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.

Function Documentation

◆ free_value()

free_value(v)

◆ push_value()

push_value(vm,
make_string("") )

Variable Documentation

◆ break

break

Definition at line 75 of file get.c.

◆ OP_CURL_GET

case OP_CURL_GET

Definition at line 39 of file get.c.