This is an automated email from the ASF dual-hosted git repository.

Xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new ba17a2a96d fix(services/gcs): request stored gzip bytes on media reads 
(#9096)
ba17a2a96d is described below

commit ba17a2a96dbdaa3793dc50b3889a3983219a6801
Author: Xuanwo <[email protected]>
AuthorDate: Thu Nov 26 04:17:22 2026 +0800

    fix(services/gcs): request stored gzip bytes on media reads (#9096)
---
 core/services/gcs/src/core.rs | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/core/services/gcs/src/core.rs b/core/services/gcs/src/core.rs
index cd78662cfd..76a7da8ebe 100644
--- a/core/services/gcs/src/core.rs
+++ b/core/services/gcs/src/core.rs
@@ -26,6 +26,7 @@ use constants::*;
 use http::Request;
 use http::Response;
 use http::StatusCode;
+use http::header::ACCEPT_ENCODING;
 use http::header::CACHE_CONTROL;
 use http::header::CONTENT_DISPOSITION;
 use http::header::CONTENT_ENCODING;
@@ -204,7 +205,8 @@ impl GcsCore {
         }
         let url = url.finish();
 
-        let mut req = Request::get(&url);
+        // Request the stored gzip bytes so GCS honors Range and agrees with 
stat.
+        let mut req = Request::get(&url).header(ACCEPT_ENCODING, "gzip");
 
         if let Some(if_match) = args.if_match() {
             req = req.header(IF_MATCH, if_match);
@@ -1773,6 +1775,19 @@ mod tests {
         );
     }
 
+    #[test]
+    fn test_media_get_accepts_stored_gzip() {
+        let core = test_core();
+        let args = read_args(options::ReadOptions::default());
+
+        for range in [BytesRange::default(), BytesRange::new(5, Some(8))] {
+            let request = core
+                .gcs_get_object_request("object", range, &args)
+                .expect("media request must build");
+            assert_eq!(request.headers()[ACCEPT_ENCODING], "gzip");
+        }
+    }
+
     #[test]
     fn test_get_object_request_with_version() {
         let core = test_core();

Reply via email to