HttpService:RequestAsync() should have compress (gzip) option

As a Roblox Developer, it’s impossible to compress (gzip) requests through the :RequestAsync() option. Roblox offers a compress=true option in PostAsync().

Roblox should offer a compress gzip option. This will:

  • Make the HttpService:RequestAsync API cleaner
  • Bring the HttpService:RequestAsync up to par in ability with :PostAsync() method
  • Improve cost of Http requests
43 Likes

It would be nice to have this as a option as it would save us and roblox precious bandwidth.
5 years later and RequestAsync still isn’t quite on par with PostAsync in all aspects.

4 Likes

Bumping this as I would still very much like this. There is an issue I am debugging with a server, and PostAsync fails if the status code isn’t 2xx. However, in order to use RequestAsync to be able to retrieve this data, I have to give up compression.

4 Likes

Bumping. Current in-dev experience relies heavily on external infra, and compressing our data is incredibly valuable to us. It would save a lot of network egress / ingress cost on GCP

1 Like

Hi, we’re looking into this. Here’s another post from a user.

80% of the cloud costs are network egress. Implementing this could reduce user cloud computation costs by like 50%.

6 Likes

Is there any update on this?
I assume it’s not high priority but this is still a good thing to have for us developers with external infrastructure, so knowing where this is along in the pipeline would be nice.

3 Likes

No ETA, but farther along than something we just want to have. The API proposal for this was accepted a while ago, but I think the team responsible for it has been busy.

2 Likes

It looks like feature flags are going live for this. “EnableRequestAsyncCompression_Rollout” went to “True;30;2023-12-13T22:35:40” Does this mean we will see this soon?

2 Likes

Many developers (including myself) use InfluxDB to store analytics and metrics. The recommended way by InfluxDB is to use gzip compression when uploading data.

I’m unable to do that, and suffer from performance issues when using RequestAsync because of that. Using PostAsync isn’t ideal as we don’t get the same level of verbosity to handle http responses.

Looks like roblox finally enabled it!
In order to use it right now you have to add a field called Compress with the value of Gzip.
Far as I can tell Gzip is the only option right now and it’s case sensitive, also it appears they do some sort of cost analysis and it may not compress all of the time.
For example if I have a body of 23 A’s it will compress, but if I have 22 it won’t compress it at all.

1 Like

Yes, this is enabled–I forgot to update everyone here on that. It’s case sensitive because it’s an enum :slight_smile:

HttpService:RequestAsync({
    Compress = Enum.HttpCompression.Gzip,
})

We are updating the documentation to include this.

19 Likes

Hey @Dogekidd2012, I found a problem when using gzip compression.
When using gzip compression, the Content-Length header is not being set correctly.
For webservers which checks the Content-Length header, this is a huge problem as it will yield an error which means the HTTP request won’t be processed.

2 Likes

Good catch! I’ll file a bug in our internal tracker for this. Alternatively, if you can post bug reports, please file one as it is much more convenient.

Thank you so much! I would have posted a bug report, but I don’t have the permissions for it.

1 Like

I just looked into this and there doesn’t appear to be an issue from our end. I hosted this Python server and it worked as expected:

import http.server
import gzip

class Handler(http.server.BaseHTTPRequestHandler):
    def do_POST(self):
        print(self.headers)
        content_length = int(self.headers.get('Content-Length'))
        body = self.rfile.read(content_length)

        print(body)

        if self.headers.get('Content-Encoding') == 'gzip':
            print(gzip.decompress(body))
                
with http.server.HTTPServer(('', 8000), Handler) as server:
    server.serve_forever()

4 Likes

Turns out fastify does not support compression on their end… Opps

is it enabled for JSONDecode too?