Skip to content

Commit

Permalink
Allow disabling Ranges (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonsturgeon authored Aug 1, 2023
1 parent 8c72f32 commit 5e00516
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lua/gm_express/sh_helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ express.timeout = CreateConVar(
"express_timeout", tostring( CLIENT and 280 or 60 ), FCVAR_ARCHIVE,
"The timeout in seconds for Express HTTP requests. (Flaky/slow connections should set this higher)", 1
)
express.useRanges = CreateConVar(
"express_use_ranges", tostring( 1 ), FCVAR_ARCHIVE + FCVAR_REPLICATED,
"Whether or not to request data in Ranges. (Improves stability for bad internets, might avoid some bugs)", 0, 1
)

-- Useful for self-hosting if you need to set express_domain to localhost
-- and direct clients to a global IP/domain to hit the same service
Expand Down Expand Up @@ -220,8 +224,10 @@ function express:Get( id, cb )
end

makeRequest = function()
-- We have to add 0-1 or the http call will fail :(
headers.Range = string.format( "bytes=%d-%d, 0-1", rangeStart, rangeEnd )
if express.useRanges:GetBool() then
-- We have to add 0-1 or the http call will fail :(
headers.Range = string.format( "bytes=%d-%d, 0-1", rangeStart, rangeEnd )
end
-- print( "Express: Downloading chunk " .. rangeStart .. " to " .. rangeEnd .. " of " .. id )

express.HTTP( {
Expand Down

0 comments on commit 5e00516

Please sign in to comment.