English | 中文
HTTP network request functions provided by SO3UI module.
Source: Source/Client/SO3UI/kschemescripttable.cpp
Send an HTTP POST request asynchronously.
CURL_HttpPostEx(szKey, szUrl, szData, fnCallback, tHeaders)| Parameter | Type | Description |
|---|---|---|
| szKey | string |
Unique request identifier (automatically prefixed with __addon_) |
| szUrl | string |
Target URL |
| szData | string |
POST data body |
| fnCallback | function |
Callback function function(bSuccess, szContent) |
| tHeaders | table |
Optional: HTTP headers table {["Content-Type"] = "application/json"} |
Returns: void
Event: CURL_REQUEST_RESULT - Fired when request completes
arg0: Request keyarg1: Success booleanarg2: Response contentarg3: Content size
Example:
CURL_HttpPostEx("myrequest", "https://api.example.com/data",
JsonEncode({name = "test"}),
function(bSuccess, szContent)
if bSuccess then
local data = JsonDecode(szContent)
Output(data)
end
end,
{["Content-Type"] = "application/json"}
)Download a file from URL.
CURL_DownloadFile(szKey, szUrl, szFilePath, bSSL, nConnTimeout, nTimeout)| Parameter | Type | Description |
|---|---|---|
| szKey | string |
Unique request identifier |
| szUrl | string |
File URL |
| szFilePath | string |
Local file path to save |
| bSSL | boolean |
Optional: Use SSL verification (default: false) |
| nConnTimeout | number |
Optional: Connection timeout in seconds (default: 10) |
| nTimeout | number |
Optional: Total timeout in seconds (default: -1, no limit) |
Returns: void
Events:
CURL_PROGRESS_UPDATE- Fired during download progressarg0: Request keyarg1: Total download sizearg2: Downloaded sizearg3: Total upload sizearg4: Uploaded size
CURL_DOWNLOAD_RESULT- Fired when download completesarg0: Request keyarg1: Success booleanarg2: File patharg3: File size
Close/cancel a CURL request.
CURL_Close(szKey)| Parameter | Type | Description |
|---|---|---|
| szKey | string |
Request identifier to close |
Returns: void
The following functions exist in source but are commented out in addon API and cannot be used:
CURL_HttpPostEx instead.
-- Commented out in addonapi.lua
-- CURL_HttpRqst(szKey, szUrl, bSSL, nTimeout)Source signature:
// LuaCURL_HttpRqst(Lua_State *L)
// Parameters: szKey, szUrl, bSSL (optional), nTimeout (optional)CURL_HttpPostEx instead.
-- Commented out in addonapi.lua
-- CURL_HttpPost(szKey, szUrl, szData/tData, bSSL, nConnTimeout, nTimeout, tHeaders)Source signature:
// LuaCURL_HttpPost(Lua_State *L)
// Parameters: szKey, szUrl, szData or table, bSSL (optional), nConnTimeout (optional), nTimeout (optional), tHeaders (optional)