gcsf icon indicating copy to clipboard operation
gcsf copied to clipboard

gzip compression

Open harababurel opened this issue 6 years ago • 7 comments

Google suggests enabling gzip compression before transferring files over the network:

In order to receive a gzip-encoded response you must do two things: Set an Accept-Encoding header, and modify your user agent to contain the string gzip. Here is an example of properly formed HTTP headers for enabling gzip compression:

Accept-Encoding: gzip
User-Agent: my program (gzip)

Find a way to enable this option in GCSF.

harababurel avatar Jun 27 '18 10:06 harababurel

Hi, @harababurel. I would like to pick this up. 😃

briankabiro avatar Jul 02 '18 12:07 briankabiro

Great news! Let me know if I can be of any help.

harababurel avatar Jul 02 '18 16:07 harababurel

Noticed that we use hyper for network requests and that we'll have to pass the headers on every request that we make to Google Drive. Looking at how I can do that now.

Did you have any ideas on the approach to take?

briankabiro avatar Jul 06 '18 06:07 briankabiro

https://github.com/harababurel/gcsf/blob/574f3fd904f7119310aa2c8ed2d14e62a3f8a896/src/gcsf/drive_facade.rs#L27

gcsf uses hyper with the google_drive3 Crate, I don't see how we can add the gzip. I've only found something related to gzip in the hyper Crate here:

https://github.com/hyperium/hyper/blob/d42c983e3bfa2983bd563705e4cb76ad865a856c/src/proto/h1/role.rs#L801

I hope this helps!

MatMercer avatar Jul 07 '18 22:07 MatMercer

Thanks for the pointer!

I think the link shows that we can indeed use gzip by appending it to the headers when forming the request. The piece of code in the snippet checks that chunked is appended to Transfer Encoding when it is passed in as a header.

Gotten this from req.headers_mut().insert("content-type", HeaderValue::from_str("application/json")?); from the Hyper docs. Looking at how to integrate it with what we have.

briankabiro avatar Jul 10 '18 05:07 briankabiro

Haven't gotten any further with this, @harababurel - apologies for not speaking up sooner.

briankabiro avatar Oct 09 '18 17:10 briankabiro

No worries -- I haven't had much time lately to work on the project either.

harababurel avatar Oct 10 '18 09:10 harababurel