I've not tried implementing this directly as middleware, but if you've got your data compressed, setting the content-encoding header to 'br' should allow the browser to decompress it automatically. For example, in an XData service endpoint, it looks like this.
I want my server to support brotli response compress just like gzip/deflate, thats why I want to implement it as middleware(just as the brotli decompress that I have allready done on server, when client send brotli compressed content).
The easiest way to accomplish this is to copy/paste the source code from Sparkle.Middleware.Compress. It's not trivial code, thus using what exists as base helps, as then you only need to change the part that actually uses the ZLib algorithm by your custom compression algorithm.
For non-web client-side decompression, you have to use event OnResponseReceived to process the raw response received and set the new response with the uncompressed value.
Hi, I'm triying with the following code with no success.
Result.HttpClient.OnResponseReceived :=
procedure(ARequest: THttpRequest; var AResponse: THttpResponse)
begin
if AResponse.Headers.Get('content-encoding') = 'br' then
begin
var NewContent : TBytes;
And actually didnt understand how to do the following from the documentation "The AResponse object is passed by reference meaning you can replace it by another one in case you want to alter the response for further processing of the framework..."