Title: GZip Compression on HTTP Server Post by: jorgen on October 06, 2014, 02:26:23 PM I now use
unit rtcZLib; like TRtcDataServer(Sender).Response['Content-Encoding'] := 'deflate'; WriteEx(ZCompress_Ex(RtcStringToBytes(AValue), zcDefault)); // using default compression strength This works on IOS, but not on Android http://zoompf.com/blog/2012/02/lose-the-wait-http-compression It seems to be better to use GZip How can I best add GZip compression? Do you have any samples on that? Jørgen Title: Re: GZip Compression on HTTP Server Post by: D.Tkalcec (RTC) on October 06, 2014, 04:45:52 PM You won't be able to do what you want with functions included in the rtcZLib unit included in the RTC SDK, because that unit only includes raw compression and decompression functions required for RTC remote functions. But, you might be able to find what you need in the zLib unit from Delphi.
Best Regards, Danijel Tkalcec Title: Re: GZip Compression on HTTP Server Post by: jorgen on October 07, 2014, 08:24:33 AM This worked
with TRtcDataServer(Sender) do begin TRtcDataServer(Sender).Response.ContentType := 'application/json'; if Request.Complete then begin TRtcDataServer(Sender).Response['Content-Encoding'] := 'gzip'; Write(GZCompressStr(AValue)); end; end; Is this the best solution? Jørgen Title: Re: GZip Compression on HTTP Server Post by: D.Tkalcec (RTC) on October 07, 2014, 12:04:25 PM Well ... you've said that it works and it's quite simple, which makes it a good solution in my book :)
PS. You can move all the code for preparation of the response headers into the "if Request.Complete then" block, unless you want it to be executed for every chunk of the request data received. Best Regards, Danijel Tkalcec |