gcsf
gcsf copied to clipboard
gzip compression
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-Encodingheader, 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.
Hi, @harababurel. I would like to pick this up. 😃
Great news! Let me know if I can be of any help.
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?
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!
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.
Haven't gotten any further with this, @harababurel - apologies for not speaking up sooner.
No worries -- I haven't had much time lately to work on the project either.