Skip to content

Setting and Listing Options

Qriist edited this page Sep 17, 2026 · 7 revisions

Setting Options

SetOpt configures a single option on an easy handle. The first parameter is the option name, the second is the value.

curl.SetOpt("URL", "https://example.com")
curl.SetOpt("FOLLOWLOCATION", 1)
curl.SetOpt("MAXREDIRS", 30)
curl.SetOpt("USERAGENT", "LibQurl/1.0")

Option names accept three equivalent forms. Bare names are the preferred style in this wiki. See Terminology and Conventions for the full explanation.

Most options do not require a handle parameter. It defaults to the first created easy handle. Pass one explicitly when you have multiple:

curl.SetOpt("URL", "https://example.com", easy_handle)

Getting Options

GetOpt returns the current value of an option, or Null() if it was never set.

val := curl.GetOpt("USERAGENT")
if (Type(val) = "Null")
    MsgBox "USERAGENT is not set."
else
    MsgBox val

Listing Options

ListOpts returns a human-readable string of all options currently set on a handle.

MsgBox curl.ListOpts()
; or for a specific handle:
MsgBox curl.ListOpts(easy_handle)

Common CURLOPT Options

LibQurl exposes the full libcurl option set. The following are some of the the most frequently used. For the complete list, see the libcurl options reference.

Common CURLOPTs
Option Purpose
URL Target URL for the transfer.
CUSTOMREQUEST Override the HTTP verb. e.g. "PUT", "DELETE", "PATCH".
POST / POSTFIELDS Enable and set POST body data. Usually set via SetPost().
UPLOAD Enable upload mode. Usually set via SetUpload().
HTTPHEADER Custom request headers. Usually set via SetHeaders().
CAINFO Path to CA certificate bundle for SSL verification.
FOLLOWLOCATION Follow HTTP redirects. On by default.
MAXREDIRS Redirect limit. Default 30.
TIMEOUT Total transfer timeout in seconds.
CONNECTTIMEOUT Connection timeout in seconds.
USERAGENT Value for the User-Agent header.
ACCEPT_ENCODING Accepted compression encodings. Empty string enables all. On by default.

Multi Handle Options

MultiSetOpt configures options on a multi handle. The naming convention is the same bare-name style:

curl.MultiSetOpt("MAXCONNECTS", 10)
curl.MultiSetOpt("MAX_HOST_CONNECTIONS", 25)

MultiGetOpt retrieves them:

val := curl.MultiGetOpt("MAXCONNECTS")
if (Type(val) = "Null")
    MsgBox "MAXCONNECTS is not set."

For the full list of multi options, see the libcurl multi interface reference.

Discovering what SetOpt parameters your libcurl supports

LibQurl uses the documented option discovery API to extract SetOpt constants as it loads. Therefore, you can determine what is known to your copy of libcurl by inspecting curl.Opt`:

; All CURLOPT options known to your version of libcurl
MsgBox curl.PrintObj(curl.Opt)

Where to Go Next

Clone this wiki locally