I need to know how to print “HTTPService Disabled” if HTTP Requests are disabled
I have tried ways to do it however I have found no solution.
I have tried to google it and multiple things however I did not find any way.
Here is an example of what I mean.
local HttpService = game:GetService("HttpService")
if HttpService.Enabled == false
then print("Applications System Warning: HTTPService being disabled will make this script not work")
(Sorry if I put this in the wrong section or something, I am new)
Thank you, is there any way to detect if it false or not through code? Since I need it to be like this
isHttpEnabled = pcall(function()
game:GetService("HttpService"):GetAsync({Url = "example.com", Method = "POST"})
end)
print("Is Http Service enabled?")
print(isHttpEnabled)
if (isHttpEnabled) == false then print("Applications System Warning: HTTPService being disabled will make this script not work")
And I encountered a bit of a glitch, it says false even if it’s true
You should check the returned value from the request as well as what others have mentioned because if your request fails, it’s going to say that HTTP requests are disabled, regardless of its true status:
local httpService = game:GetService('HttpService')
local successful, result = pcall(httpService.GetAsync, httpService, 'https://google.com')
if successful then
print('HTTP requests are enabled!')
elseif result:lower():find('http requests are not enabled') then
warn('HTTP requests are not enabled!')
else
warn('Invalid HTTP request:',result)
end
If we request to some random site, the returned data is the reason the request failed instead of automatically assuming HTTP requests are off:
local httpService = game:GetService('HttpService')
local successful, result = pcall(httpService.GetAsync, httpService, 'https://asddasdasdiwehfwierfhwekjfwqkjbhfewnljkqefwnjl.com')
if successful then
print('HTTP requests are enabled!')
elseif result:lower():find('http requests are not enabled') then
warn('HTTP requests are not enabled!')
else
warn('Invalid HTTP request:',result) --> Invalid HTTP request: HttpError: DnsResolve, curlCode:6, curlMsg:Could not resolve host: asddasdasdiwehfwierfhwekjfwqkjbhfewnljkqefwnjl.com
end