How do I check if HTTP Requests are disabled for an applications system?

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)

1 Like

It’s a bit hacky, but this should work: (edited)

isHttpEnabled = pcall(function()
    game:GetService("HttpService"):RequestAsync({Url = "example.com", Method = "POST"})
end)

print("Is Http Service enabled?")
print(isHttpEnabled)
2 Likes

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

that’s because he was thinking about the wrong method when he wrote the code in the pcall, what you want to use instead of GetAsync is RequestAsync.

My mistake, forgot to change that back!

1 Like

I tried that now, it still says false even though it is on.

1 Like

I found that the issue was the link he used for it was incorrect and it thought it was a Roblox link or a mistrusted link, this should work:

isHttpEnabled = pcall(function()
    game:GetService("HttpService"):RequestAsync({Url = "https://example.com", Method = "GET"})
end)

print("Is Http Service enabled?")
print(isHttpEnabled)

cc @Naco88, @Reapimus

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
3 Likes