redarrowlabs / Argo

:squirrel: c# object => json.api relational mapping
MIT License
7 stars 3 forks source link

gzip compression #31

Closed engenb closed 7 years ago

engenb commented 7 years ago

gzip is a defacto standard for compressing transport data between clients and servers. textual information like json can be compressed to ~20% its original size with minimal cpu overhead.

can probably add something to IConfigureRemote like .UseGzip() that will add an additional DelegatingHandler to the HttpClient request pipeline with something like this:

using (var Stream = new MemoryStream())
{
    using (var Zipper = new GZipStream(Stream, CompressionMode.Compress, true)) Zipper.Write(Bytes, 0, Bytes.Length);
    var Content = new ByteArrayContent(Stream.ToArray());
    Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
    Content.Headers.ContentEncoding.Add("gzip");
    return Content;
}
engenb commented 7 years ago

doing this would be much easier AFTER #35 is completed

engenb commented 7 years ago

after closing this, I realized I only configured HttpClient to notify the server it supported gzip and decompress the response. now adding ability to gzip the request