#1 2013-05-20 14:34:07

ah
Member
Registered: 2013-05-17
Posts: 9

Compression in Interface-based methods

I'm using a simple method to execute SQL at server-side (based on the Sample provided):

  IRemoteDatabase = interface(IInvokable)
    function Execute(const aSQL: RawUTF8; aExpectResults: boolean; const Params: RawJSON): RawJSON;

I'm generating the content of RawJSON parameters using TJSONWriter and reading them using TSQLTableJson.
Are those contents being compressed for transmission, by default? If not, what is the easiest way to do it (especially the function result of course, which is the RawJSON return value).

Offline

#2 2013-05-20 16:25:44

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Compression in Interface-based methods

Via HTTP, content is compressed using either our SynLZ algorithm, either Zip/defalte.

Online

#3 2013-05-21 14:45:00

ah
Member
Registered: 2013-05-17
Posts: 9

Re: Compression in Interface-based methods

I bet it is, but how do I choose it? When debugging mormot and inspecting variables, it seems there is no compression.
I changed my source code in client with this:

    FClient := TSQLHttpClient.Create(AnsiString(Self.Host), AnsiString(IntToStr(Self.Port)), FModel);
    FClient.Compression := [hcSynLZ, hcDeflate]; // ADD THIS

Now I see Accept header is being sent in the http request from the client, but I'm trying to debug the server and I don't see a header of Content-Encoding.
Should setting FClient.Compression be enough? Or do I have to do something else on the server, or anywhere else?

Offline

#4 2013-05-21 15:11:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Compression in Interface-based methods

Compression and Content-Encoding is not handled at ORM / mORMot.pas level, but at transmission protocol level.

So you won't see it at Server side at TSQLRestServer.URI() level, but within each per-thread THttpServer running class.
On the server side, by default both Deflate and SynLZ are always available.

hcSynLZ kind of compression will work for Delphi clients only, but gives the better compression/CPU ratio possible, especially on Server side.

Online

Board footer

Powered by FluxBB