RTC Forums
May 18, 2024, 07:27:05 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Compression on HTTP Server  (Read 4959 times)
ManfredPfeiffer
RTC License++
*****
Posts: 14


« on: September 03, 2012, 09:47:01 PM »

Danijel,

I am writing a HTTP server which sends SVG images to mobile devices. Is there any way to send the response compressed (gzip)?

Kind regards,
Manfred
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: September 03, 2012, 09:54:15 PM »

You can set HTTP headers to let the Client know what your content will be compressed and use a compression library to compress the content body before you send it out. Because only the content body is being compressed when using "gzip" over HTTP/S, you have full control over the process.

Best Regards,
Danijel Tkalcec
Logged
ManfredPfeiffer
RTC License++
*****
Posts: 14


« Reply #2 on: September 04, 2012, 05:24:18 AM »

Could your ZCompress_Str be used for the compression?
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: September 04, 2012, 08:34:34 AM »

Besauce the RTC SDK uses "zlib", you may be able to use the included ZCompress/ZDecompress functions to work with "deflate" Content-Encoding, but I don't think it will work for "gzip", because that is a different format.

Best Regards,
Danijel Tkalcec
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #4 on: September 04, 2012, 10:08:25 AM »

I've just ran a short test using the RTC SDK v6.0 RC2 and this seems to be working for sending out "deflate" compressed files:
Code:
uses rtcInfo, rtcZLib;

function SendDeflateCompressed(Srv:TRtcDataServer; const filename:String);
  begin
  Srv.Response['Content-Encoding']:='deflate';
  Srv.WriteEx(ZCompress_Ex(Read_FileEx(filename),zcDefault));
  end;

Here is the same for RTC SDK v5.x and older:
Code:
uses rtcInfo, rtcZLib;

function SendDeflateCompressed(Srv:TRtcDataServer; const filename:String);
  begin
  Srv.Response['Content-Encoding']:='deflate';
  Srv.Write(ZCompress_Str(Read_File(filename),zcDefault));
  end;

Best Regards,
Danijel Tkalcec
Logged
ManfredPfeiffer
RTC License++
*****
Posts: 14


« Reply #5 on: September 04, 2012, 11:16:28 AM »

"Deflate" works fine with Zcompress_str - thank you very much!
Logged
ManfredPfeiffer
RTC License++
*****
Posts: 14


« Reply #6 on: September 04, 2012, 11:19:05 AM »

Sorry - didn't see your last post before I replied. Is it possible to integrate compression into the properties of HTTPServer (similar to Intraweb)?

Kind regards,
Manfred
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #7 on: September 04, 2012, 12:46:29 PM »

TRtcHttpServer is a general-purpose HTTP/S Server, where you have full control over all data going in and out. Adding support for a specific content compression/decompression algorithm at such a low level would not be possible, without restricting what you can do with the components.

PS. TRtcServerModule and TRtcClientModule components have built-in automatic compression and decompression support, because all data going in and out is under component control (and not user control).

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.025 seconds with 15 queries.