Skip to content
Qriist edited this page Sep 17, 2026 · 16 revisions

LibQurl

The guiding principle of LibQurl is to abstract away most of the lifetime management minutiae that the average AHKv2 user would find frustrating about libcurl.

However, abstracted does not mean absent. There are an immense number of ways to productively use libcurl for network transactions. The supplied defaults are therefore intended to be sane without becoming restrictive.

As you read the documentation, keep in mind that almost everything in libcurl runs off of some variety of handle. While you won't see many in the examples, it can be assumed that any "handleless" call uses an internally-supplied default handle when the final parameter is unset. The API Reference at the bottom of the sidebar contains the full signature of every implemented method if you're ever in doubt.

See Getting Started for installation, SSL backend selection, and full setup.

Quick Example

This is the minimum viable transfer:

curl := LibQurl()
curl.SetOpt("URL", "https://httpbin.org/get")
curl.Sync()
body := curl.GetLastBody()
Explanation
  • LibQurl() loads the DLL, initializes libcurl, probes and selects the SSL backend (WolfSSL default), creates the initial easy_handle, sets sensible defaults (compression, redirects, error buffer, cert bundle), and soft-prepares the Magic download target.

  • SetOpt("URL", ...) stores the value in the handle's options record and calls curl_easy_setopt under the hood to set libcurl's network destination.

  • Sync() initializes the Magic storage destination, then calls curl_easy_perform. libcurl handles DNS, TCP, TLS, the HTTP request, and the response write. On completion, ClearPost is invoked automatically.

  • GetLastBody() retrieves the stored body from the handle map, detects whether it landed as a Buffer or a File, and returns it as a UTF-8 string.

Highlights

  • Full direct binding of libcurl. All known functions accessible.
  • The vast majority of functionality wrapped with sensible defaults.
  • Numerous simultaneous handles. Multi (Async) interface supported. All options remembered per-handle.
  • Compressed transfers on by default.
  • Download directly into RAM without touching disk.
  • A unique "magic" hybrid mode: starts in memory, flushes to disk at a size threshold.
  • Effortless POSTing from String, Integer, Object, Array, Map, Buffer, or FileObject.
  • Effortless MIME form building with the same smart source handling.
  • Manual WebSocket traffic and protocol-level raw data.
  • Full Aris support. Recommended install method.

What's in This Wiki

  • Foundations — installation, terminology, error model
  • Operations — step-by-step guides grounded in working test cases
  • API Reference — per-handle method reference with signatures and return values
  • Code Snippets — excerpts taken from real projects using the library

Clone this wiki locally