Skip to content

Commit

Permalink
Some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown-gd committed Jul 14, 2023
1 parent e4a3454 commit c93166e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lua/gpm/http.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ if SERVER then
end
end

-- HTTP client
Client = reqwest or CHTTP or HTTP

local queue = {}
util.NextTick( function()
for _, func in ipairs( queue ) do
Expand All @@ -22,10 +25,9 @@ util.NextTick( function()
queue = nil
end )

local HTTP = reqwest or CHTTP or HTTP
local function client( parameters )
local function request( parameters )
logger:Debug( "%s HTTP request to %s (timeout %d sec)", parameters.method, parameters.url, parameters.timeout )
return HTTP( parameters )
return Client( parameters )
end

local timeout = CreateConVar( "gpm_http_timeout", "10", FCVAR_ARCHIVE, "Default http timeout for gpm http library.", 5, 300 )
Expand Down Expand Up @@ -63,10 +65,10 @@ local function asyncHTTP( parameters )

if queue ~= nil then
queue[ #queue + 1 ] = function()
client( parameters )
request( parameters )
end
else
client( parameters )
request( parameters )
end

return promise
Expand Down

0 comments on commit c93166e

Please sign in to comment.