#1 2024-07-26 08:41:09

danielkuettner
Member
From: Germany
Registered: 2014-08-06
Posts: 341

issue with new IsContentTypeCompressible(pointer(OutContentType))

Hi ab,

since commit #ebba3ec http response in browser client is compressed because of this line in mormot.net.http.pas:

compressible := IsContentTypeCompressible(pointer(OutContentType));

Do I have to set/config something to prevent this?
My ContentType is application/json.

When changing line 8903 in mormot.core.buffers.pas to this

_CONTENT_APP: array[0..4] of PUtf8Char = (
    'APPLICATION/JSON', <-- this works for me
    'XML',
    'JAVASCRIPT',
    'VND.API+JSON',
    nil);

it work as expected.

Daniel

Last edited by danielkuettner (2024-07-26 08:59:02)

Offline

#2 2024-07-26 14:20:54

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

Re: issue with new IsContentTypeCompressible(pointer(OutContentType))

Shouldn't application/json be compressed?

I have included some associated regression tests:
https://github.com/synopse/mORMot2/commit/50c20c00

Offline

#3 2024-07-26 14:55:23

danielkuettner
Member
From: Germany
Registered: 2014-08-06
Posts: 341

Re: issue with new IsContentTypeCompressible(pointer(OutContentType))

I'm not the one who defines which ContentType hast to be compressed. But over the last 10 years I'm using this ContentType and it was never compressed.
Should be compressing not independent from ContentTypes and compressing tagged by other headers:

Content-Type:application/json - tells what type of content data in the http call
Content-Encoding: gzip - tells what compression being used

Anyway, I need a way to disable compressing, because it isn't nice to decompress synlz compressed responses by browser/js.

Last edited by danielkuettner (2024-07-26 15:21:08)

Offline

#4 2024-07-26 16:43:56

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

Re: issue with new IsContentTypeCompressible(pointer(OutContentType))

You are right, a browser is not able to handle SynLZ compression.

But since the browser does not add the "SynLZ" compression int its supported encoding, the server should never use this compression.
In CompressContent(), SynLZ should never be part of the Accepted: THttpSocketCompressSet value, so the browser should never use SynLZ.
Only if the browser notify about "gzip", then the server would try to compress using gzip.

Offline

#5 2024-07-26 18:10:52

Márcio Baroni
Member
From: Brasil
Registered: 2015-10-07
Posts: 33

Re: issue with new IsContentTypeCompressible(pointer(OutContentType))

The problem is in unit mormot.net.http.pas line 2770

 for i := 1 to length(Handled) do 

correct would be

 for i := 0 to length(Handled) do 

Offline

#6 2024-07-26 18:13:50

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

Re: issue with new IsContentTypeCompressible(pointer(OutContentType))

Oh yes, there was a regression about the index in Accepted.

SHould be fixed now with
https://github.com/synopse/mORMot2/commit/a94b7249

Thanks a lot Marcio for your very valuable input!

Offline

#7 2024-07-26 18:26:35

danielkuettner
Member
From: Germany
Registered: 2014-08-06
Posts: 341

Re: issue with new IsContentTypeCompressible(pointer(OutContentType))

@Márcio Baroni
Thanks a lot

Offline

Board footer

Powered by FluxBB