From 7af80b565d71b11078b28fadd731944dfb8df83a Mon Sep 17 00:00:00 2001 From: Martin <92585539+MartinYacovlev@users.noreply.github.com> Date: Sun, 8 Feb 2026 21:26:23 +0300 Subject: [PATCH 1/2] Update http_client.lua replace HTTP to CHTTP (TLS/HTTP/2.0) --- lua/azlink/http/http_client.lua | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lua/azlink/http/http_client.lua b/lua/azlink/http/http_client.lua index f516e95..3f3c33f 100755 --- a/lua/azlink/http/http_client.lua +++ b/lua/azlink/http/http_client.lua @@ -1,10 +1,10 @@ -local httpClient = { +local httpClient = { timeout = 5000 } -function httpClient:Request( requestMethod, endpoint, data ) - return AzLink.Promise( function( onResolve, onReject ) - HTTP( { +function httpClient:Request(requestMethod, endpoint, data) + return AzLink.Promise(function(onResolve, onReject) + local request = CHTTP({ method = requestMethod, url = AzLink.config.url .. "/api/azlink" .. endpoint, timeout = self.timeout, @@ -13,22 +13,22 @@ function httpClient:Request( requestMethod, endpoint, data ) ["Accept"] = "application/json", ["Content-Type"] = "application/json", }, - type = "application/json", - body = data and util.TableToJSON( data ) or nil, - success = function( code, body ) - local jsonBody = body and util.JSONToTable( body ) or body + body = data and util.TableToJSON(data) or nil, + success = function(code, body, headers) + local jsonBody = body and util.JSONToTable(body) or body if code >= 300 then - onReject( jsonBody.message or body, code ) - + onReject(jsonBody.message or body, code) return end - onResolve( jsonBody ) + onResolve(jsonBody) + end, + failed = function(error) + onReject(error) end, - failed = onReject, - } ) - end ) + }) + end) end AzLink.HttpClient = httpClient From 96d552666a154e890c220cb97b06fe50539d1b40 Mon Sep 17 00:00:00 2001 From: MrMicky Date: Wed, 11 Feb 2026 08:02:38 +0100 Subject: [PATCH 2/2] Fallback to default HTTP if CHTTP is not installed --- lua/azlink/http/http_client.lua | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/lua/azlink/http/http_client.lua b/lua/azlink/http/http_client.lua index 3f3c33f..3770fa3 100755 --- a/lua/azlink/http/http_client.lua +++ b/lua/azlink/http/http_client.lua @@ -1,10 +1,17 @@ local httpClient = { timeout = 5000 } +local httpRequest -function httpClient:Request(requestMethod, endpoint, data) - return AzLink.Promise(function(onResolve, onReject) - local request = CHTTP({ +if pcall( require, "chttp" ) and CHTTP ~= nil then + httpRequest = CHTTP +else + httpRequest = HTTP +end + +function httpClient:Request( requestMethod, endpoint, data ) + return AzLink.Promise( function( onResolve, onReject ) + httpRequest( { method = requestMethod, url = AzLink.config.url .. "/api/azlink" .. endpoint, timeout = self.timeout, @@ -13,22 +20,22 @@ function httpClient:Request(requestMethod, endpoint, data) ["Accept"] = "application/json", ["Content-Type"] = "application/json", }, - body = data and util.TableToJSON(data) or nil, - success = function(code, body, headers) - local jsonBody = body and util.JSONToTable(body) or body + type = "application/json", + body = data and util.TableToJSON( data ) or nil, + success = function( code, body ) + local jsonBody = body and util.JSONToTable( body ) or body if code >= 300 then - onReject(jsonBody.message or body, code) + onReject( jsonBody.message or body, code ) + return end - onResolve(jsonBody) - end, - failed = function(error) - onReject(error) + onResolve( jsonBody ) end, - }) - end) + failed = onReject, + } ) + end ) end AzLink.HttpClient = httpClient