MoneyWorks Manual
Curl_AsyncExec (curlhandle, completionHandler)
Result Type: none
Definition: Performs the CURL operation for the given curl object in a background thread (the function returns immediately*). When the curl operation finishes, the completion handler will be called on the app's main thread.
The completionHandler should look like:
on MyCompletionHandler(curlRes, curlHandle, [payload], [headers])
CurlRes is the curl code result of the operation. You should call Curl_Close
on the curl handle once you have got what you need from it. The payload and headers will be supplied if you have not captured them by means of your own callbacks.
Example:
on CheckCurlResult(res, ch) let httpCode = Curl_GetInfo(ch, CURLINFO_RESPONSE_CODE) Curl_Close(ch) if res <> 0 syslog("[ERROR] could not reach repo: ", res) return endif if httpCode != 200 syslog("[ERROR] http error: ", httpCode) return endif // other stuff end on DoCurl ... Curl_SetOpt(ch, CURLOPT_PRIVATE, "my data") Curl_AsyncExec(ch, "CheckCurlResult") ... end
- When run in the command-line tool, the operation runs synchronously; the completion handler will be called before the function returns.
Availability: available within MWScript handlers in v9.2.3 and later.
See Also:
Base64Decode: String from a base64 encoding
Base64Encode: Base64 of a string
Curl_Close: Finish with a CURL session
Curl_Exec: Execute a CURL session
Curl_GetInfo: Get information about a CURL transfer
Curl_GetOpt: Get a handle from a curl handle
Curl_Init: Start a CURL session
Curl_StrError: Get an error message from a CURL object
URLEncode: Convert url unsafe characters in a string to "%xx”