RTC Forums
May 03, 2024, 10:51:58 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: GZip Compression on HTTP Server  (Read 3765 times)
jorgen
RTC Expired
*
Posts: 20


« 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

Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 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
Logged
jorgen
RTC Expired
*
Posts: 20


« Reply #2 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
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 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 Smiley

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
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.023 seconds with 17 queries.