mbutrovich commented on code in PR #3805:
URL: https://github.com/apache/iceberg-rust/pull/3805#discussion_r4803007224
##########
crates/catalog/rest/Cargo.toml:
##########
@@ -44,7 +44,7 @@ http = { workspace = true }
iceberg = { workspace = true }
itertools = { workspace = true }
moka = { workspace = true, features = ["sync"] }
-reqwest = { workspace = true, features = ["form", "query"] }
+reqwest = { workspace = true, features = ["form", "gzip", "query"] }
Review Comment:
> Someone could add this themselves as a consumer of the crate but I think
it's a very sensible default for us to have out of the box which is why I put
this PR up.
I agree it's a good default for the catalog. The catch is that Cargo unifies
features across a build, so enabling `gzip` here turns on decompression for
every `reqwest::Client` in any binary that links this crate, not only the
catalog's client.
That includes OpenDAL's storage client. The `opendal` facade [installs a
default
transport](https://github.com/apache/opendal/blob/fce9cdefdea7c8e54dfbaf3c88c3b6d5ec68146e/core/src/lib.rs#L46-L50)
built with
[`reqwest::Client::new()`](https://github.com/apache/opendal/blob/fce9cdefdea7c8e54dfbaf3c88c3b6d5ec68146e/core/http-transports/reqwest/src/lib.rs#L42-L43),
and `iceberg-storage-opendal` doesn't override it. In the
`iceberg-catalog-loader` build, `cargo tree -p iceberg-catalog-loader -e
normal,features -i reqwest` shows `iceberg-catalog-rest` as the only crate that
enables `gzip`. So with this PR, S3 reads there start sending `Accept-Encoding:
gzip`, and any object response that carries `Content-Encoding: gzip` comes back
decompressed instead of as the stored bytes. `object_store` [turns compression
off on its
client](https://github.com/apache/arrow-rs-object-store/blob/279572ea60f3a7a6e5237e066a6f4a35eee611e0/src/client/mod.rs#L956-L961)
to guard against this.
Should we keep gzip inside the REST client instead of enabling the reqwest
feature? `HttpClient` could set `Accept-Encoding: gzip` on the requests it
sends, and
[`HttpResponse::read`](https://github.com/apache/iceberg-rust/blob/84f5efe4c2b7046cc1139e3c7225782fb8f05432/crates/catalog/rest/src/response.rs#L58-L73)
could gunzip the body with `flate2` when `Content-Encoding` is `gzip`. Both
send paths already go through `HttpResponse::read`, and it already buffers the
whole body, so this is a few lines. Your test would cover it unchanged.
##########
crates/catalog/rest/src/catalog.rs:
##########
@@ -2775,6 +2777,42 @@ mod tests {
list_ns_mock.assert_async().await;
}
+ #[tokio::test]
+ async fn test_list_namespace_with_gzip_response() {
Review Comment:
> Happy to remove this test if we don't think it's needed but it does
protect against regressions
Please keep it. No other test in the repo serves a compressed response or
checks for `Accept-Encoding`, so this is the one that would catch the feature
getting dropped.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]