mirror of
https://github.com/CFC-Servers/cfc_cl_http_whitelist.git
synced 2025-03-04 03:03:18 -05:00
Http error code handling for PlayURL (#45)
* give bass errors for 401, 403, and 404 status codes * remove debug print * remove default code value
This commit is contained in:
parent
18b9e2f35f
commit
83b3811266
@ -18,11 +18,11 @@ function CFCHTTP.getFileType( data )
|
||||
end
|
||||
|
||||
---@param url string
|
||||
---@param callback fun( urls: string[], err: string|nil)
|
||||
---@param callback fun( urls: string[], err: string|nil, code )
|
||||
function CFCHTTP.GetFileDataURLS( url, callback )
|
||||
http.Fetch( url, function( body, _, _, code )
|
||||
if code < 200 or code > 299 then
|
||||
callback( {}, "HTTP request returned status code " .. code )
|
||||
callback( {}, "HTTP request returned status code " .. code, code )
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -31,13 +31,21 @@ local function wrapPlayURL()
|
||||
return
|
||||
end
|
||||
|
||||
CFCHTTP.GetFileDataURLS( url, function( uris, err )
|
||||
CFCHTTP.GetFileDataURLS( url, function( uris, err, code )
|
||||
if err ~= nil then
|
||||
logData.urls[1].status = "blocked"
|
||||
logData.urls[1].reason = err
|
||||
|
||||
CFCHTTP.LogRequest( logData )
|
||||
if callback then callback( nil, CFCHTTP.BASS_ERROR_BLOCKED_CONTENT, "BASS_ERROR_BLOCKED_CONTENT" ) end
|
||||
if callback then
|
||||
if code == 401 or code == 403 then
|
||||
callback( nil, 49, "BASS_ERROR_DENIED" )
|
||||
elseif code == 404 then
|
||||
callback( nil, 2, "BASS_ERROR_FILEOPEN" )
|
||||
else
|
||||
callback( nil, CFCHTTP.BASS_ERROR_BLOCKED_CONTENT, "BASS_ERROR_BLOCKED_CONTENT" )
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
if #uris == 0 then
|
||||
|
Loading…
Reference in New Issue
Block a user