Skip to content

Commit 50cf8bd

Browse files
Always explicitly disable gzip automatic decompression on reqwest client used by object_store (#6843)
* Explicitly disable gzip on reqwest client used by object_store * Add comment * Add integration test for checking reqwest gzip feature * Fix lint * Add comment explaining why gzip feature is enabled
1 parent 06a0157 commit 50cf8bd

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

object_store/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ http-body-util = "0.1"
7777
rand = "0.8"
7878
tempfile = "3.1.0"
7979
regex = "1.11.1"
80+
# The "gzip" feature for reqwest is enabled for an integration test.
81+
reqwest = { version = "0.12", features = ["gzip"] }
8082
http = "1.1.0"
8183

8284
[[test]]

object_store/src/client/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,10 @@ impl ClientOptions {
671671
builder = builder.danger_accept_invalid_certs(true)
672672
}
673673

674+
// Reqwest will remove the `Content-Length` header if it is configured to
675+
// transparently decompress the body via the non-default `gzip` feature.
676+
builder = builder.no_gzip();
677+
674678
builder
675679
.https_only(!self.allow_http.get()?)
676680
.build()

object_store/tests/http.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
//! Tests the HTTP store implementation
19+
20+
#[cfg(feature = "http")]
21+
use object_store::{http::HttpBuilder, path::Path, GetOptions, GetRange, ObjectStore};
22+
23+
/// Tests that even when reqwest has the `gzip` feature enabled, the HTTP store
24+
/// does not error on a missing `Content-Length` header.
25+
#[tokio::test]
26+
#[cfg(feature = "http")]
27+
async fn test_http_store_gzip() {
28+
let http_store = HttpBuilder::new()
29+
.with_url("https://raw.githubusercontent.com/apache/arrow-rs/refs/heads/main")
30+
.build()
31+
.unwrap();
32+
33+
let _ = http_store
34+
.get_opts(
35+
&Path::parse("LICENSE.txt").unwrap(),
36+
GetOptions {
37+
range: Some(GetRange::Bounded(0..100)),
38+
..Default::default()
39+
},
40+
)
41+
.await
42+
.unwrap();
43+
}

0 commit comments

Comments
 (0)