From 8a1023e97b77edd0d363aaa368f2da05a5005274 Mon Sep 17 00:00:00 2001 From: Yuang Gao Date: Sun, 7 Jun 2026 21:30:03 -0700 Subject: [PATCH] feat(services/obs): support if_modified_since and if_unmodified_since on read (part of #5486) --- core/services/obs/src/backend.rs | 2 ++ core/services/obs/src/core.rs | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/core/services/obs/src/backend.rs b/core/services/obs/src/backend.rs index 8ffca99f4f97..7338b195481e 100644 --- a/core/services/obs/src/backend.rs +++ b/core/services/obs/src/backend.rs @@ -206,6 +206,8 @@ impl Builder for ObsBuilder { read_with_if_match: true, read_with_if_none_match: true, + read_with_if_modified_since: true, + read_with_if_unmodified_since: true, write: true, write_can_empty: true, diff --git a/core/services/obs/src/core.rs b/core/services/obs/src/core.rs index a5d98d63df29..f2333c20144b 100644 --- a/core/services/obs/src/core.rs +++ b/core/services/obs/src/core.rs @@ -25,7 +25,9 @@ use http::header::CONTENT_DISPOSITION; use http::header::CONTENT_LENGTH; use http::header::CONTENT_TYPE; use http::header::IF_MATCH; +use http::header::IF_MODIFIED_SINCE; use http::header::IF_NONE_MATCH; +use http::header::IF_UNMODIFIED_SINCE; use opendal_core::raw::*; use opendal_core::*; use reqsign_core::{Context, Signer}; @@ -144,6 +146,14 @@ impl ObsCore { req = req.header(IF_NONE_MATCH, if_none_match); } + if let Some(if_modified_since) = args.if_modified_since() { + req = req.header(IF_MODIFIED_SINCE, if_modified_since.format_http_date()); + } + + if let Some(if_unmodified_since) = args.if_unmodified_since() { + req = req.header(IF_UNMODIFIED_SINCE, if_unmodified_since.format_http_date()); + } + let req = req .extension(Operation::Read) .extension(ServiceOperation("GetObject"))