Compress Middleware and Tstream

Hi, In Xdata I send response in Tstream format from my services, for preserve entire content (Json already formatted). But Compress MIddleware don't compress response content.
Is this "by design"? I have to compress Tstream from myself?

Compress middleware will only compress the response if some conditions are met:

  1. Client sends an accept-encoding header with value gzip or deflate
  2. Response size is bigger than the threshold specified in the middleware (1024 bytes by default)
  3. Response content-type is "compressible" (most text types, like text/html, text/plain, application/json, etc.

My test example (with Compress MIddleware in XdataServer middleware list):

function TGenService.JSONRPC(JsonRPC:string; method:string; params:TJsonObject; id:string): Tstream;
User: IUserIdentity;
if (JsonRPC <> '2.0') or (trim(method) = '') then //or (id <= 0)
raise EXDataHttpForbidden.Create('JsonRPC non conforme');
TXDataOperationContext.Current.Response.Headers.setValue('content-type', 'application/json');

But the stream is not compressed in Postman (size is always the same). Any hint on this?


Are all conditions met?

Yes, I think. In the body result there is a Json.
I thought the only reason could be the Tstream type result...

Do you have a screenshot of the Postman request headers?
Do you have a screenshot showing the size of the response?
Are you sure Postman is not automatically decompressing the response?