Add status code support to HttpService

As a Roblox developer, it is currently impossible to know what status code a server responds with when using HttpService.

Discord recently banned the use of the Roblox\WinInet user-agent string due to the fact that 88% of requests using that header did not abide by the Discord rate limits.

https://twitter.com/lolpython/status/967211473586987009
https://twitter.com/lolpython/status/967212535274340352

Due to the fact that HttpService does not support reading status code, Roblox scripts could not obey these rate limits in the official way.

(You could make predefined rate limits in the client side of things but this is not how Discord is intended to be used.)

This problem isn’t just exclusive to using Discord too, plenty of other web services communicate information about responses through the use of status codes.

18 Likes

Also response headers

9 Likes

Are you sure? I thought if you pcalled and checked the error it contained the HTTP status code:

local http = game:GetService('HttpService'):
local status, err = pcall(http.GetAsync, http, 'https://google.com/404')
print(status, err) --should print a 404 error

(I also tested this with a 429 error I generated on my own server and it printed a 429 error)

Even if the client knows they are being rate limited they are not obeying the standard if they retry before the specified retry-after. Therefore, the real problem is that you can read neither the headers nor the body of a failed request, even though it could contain important information.

1 Like