Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiFiremonkeyIOSOSXWindows

Decode GZIP Content From The REST Client In Delphi XE7 Firemonkey On Android And IOS

Delphi XE7 Firemonkey REST Client Decode GZIP ContentIf you’re building any kind of mobile app with the TRESTClient that ships with Delphi XE7 Firemonkey you’ll want it to use a minimum amount of data. One place where you can really reduce the amount of data usage is to compress the data between your REST server and your REST client app. The TRESTClient component uses TIdHTTP (and the HTTP protocol) which supports GZIP for compression. By default compression is not enabled in TRESTClient. You can enable compression by setting the TRESTRequest property AcceptEncoding to ‘gzip, deflate’. However, once the server starts sending you GZIPed content you will have to decode it. If the server supports GZIP and it gzips the contents the TRESTResponse.ContentEncoding property will be ‘gzip’. You will need to decode the content yourself at this point. For you to decode the content you can use the TRESTResponse.RawBytes property to access the data for decoding. Load the contents of RawBytes into a TMemoryStream and then use TIdCompressorZlib.DecompressGZipStream() to decompress the data. I’ve included a code snippet below. It should work on Android, IOS, OSX, and Windows plus it should compile for Appmethod as well.

Head over to the Embarcadero docwiki and check out all of the REST components available in the REST.Client unit for Delphi XE7 Firemonkey.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
AndroidC++BuilderCode SnippetDelphiDemoFiremonkeyIOSOSXShowcaseWindows

Powerful Cross Platform Email App Sample In Delphi 10.4.1 FireMonkey For Android And IOS

AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

Significant Update Available For Delphi FireMonkey 10.4.1 On Android, IOS, OSX, Windows, And Linux

C++BuilderDelphiIDEWindows

Professional SVG Icon Image List For Delphi 10.4 FireMonkey On Windows

AndroidC++BuilderDelphiFiremonkeyIOSLiveBindingsOSXWindows

Top Tips And Tricks To Speed Up Development With Delphi 10.4 FireMonkey On Android and IOS

Sign up for our Newsletter and
stay informed

3 Comments

Leave a Reply