delphi-rest-client-api
delphi-rest-client-api copied to clipboard
Support for send GZIP data
I'm using the api to send a large amount of data and need to compress the data with gzip. From what I understand the API supports GZIP in return through EnabledCompression but not in the sending.
Due to problems with XE2 in TIdCompressorZLib I'm using TZCompressionStream (System.ZLib.pas).
It would be great if we could encapsulate this routine in RESTClient.
What do you think?
I'm not familiar with the ZLib library, show me the code you are using with TZCompressionStream.
Maybe we can include that in TRestClient.DoRequest thus becomes transparent and independent of the connection layer used.
We can also define events to customize the compression and / or use other alternatives of compression.
Does that help you?
uses
System.ZLib;
procedure Compactar(Original, Compactado: TStringStream);
const
GZIP = 31;
var
CompactadorGZip: TZCompressionStream;
begin
CompactadorGZip := TZCompressionStream.Create(Compactado, zcMax, GZIP);
try
CompactadorGZip.CopyFrom(Original, Original.Size)
finally
CompactadorGZip.Free;
end;
end;
I am also setting the content-type that way
.ContentType('gzip/json')