Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

object_store returns an error when other compression features are enabled in reqwest #7142

Closed
kylewlacy opened this issue Feb 16, 2025 · 0 comments · Fixed by #7143
Closed
Labels

Comments

@kylewlacy
Copy link
Contributor

Describe the bug

#6842 describes the problems that occur when the optional gzip feature is enabled in reqwest. The fix in #6843 addressed this by calling the reqwest::ClientBuilder.no_gzip() method.

Reqwest offers other features that automatically enable compression on a supported server too: in addition to gzip, there's also deflate, brotli, and zstd. When any of these features are enabled, reqwest will include the Accept-Encoding header with supported compression formats, and supporting HTTP servers will reply with Content-Encoding indicating the accepted compression format (if any). When this happens, the Content-Length header will be set to the compressed length of the body. That is, if it's set at all-- many servers will end up omitting the header when compression is enabled.

To Reproduce

  1. Clone the example repo at this commit: kylewlacy/object_store_compression_repro@256c8c0
  2. Run cargo test within the repo

The test fails with the following error:

thread 'tests::repro' panicked at src/lib.rs:32:14:
called `Result::unwrap()` on an `Err` value: Generic { store: "HTTP", source: Header { source: MissingContentLength } }

(Example repo based on the example from #6842, thanks @phillipleblanc for making an easy-to-use example for the previous bug!)

Expected behavior

The test should pass. It passes if the zstd feature is disabled in the reqwest crate.

Additional context

This example repo uses a local Axum server with gzip/deflate/brotli/zstd compression enabled, and with the zstd feature enabled on the reqwest crate. Therefore, the default reqwest client includes Accept-Encoding: zstd in the request, and the server responds with Content-Encoding: zstd. Because compression is enabled, reqwest does not (and cannot) return the decompressed content length of the response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant