From 4c4336183c7e68f0bcf9cebc206fae52f20b823c Mon Sep 17 00:00:00 2001 From: Changxin Miao Date: Wed, 25 Feb 2026 23:30:36 +0800 Subject: [PATCH] fix(aliyun-oss): avoid duplicated bucket in canonicalized resource for path-style --- services/aliyun-oss/src/sign_request.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/services/aliyun-oss/src/sign_request.rs b/services/aliyun-oss/src/sign_request.rs index cdc48025..7884ad89 100644 --- a/services/aliyun-oss/src/sign_request.rs +++ b/services/aliyun-oss/src/sign_request.rs @@ -321,7 +321,15 @@ impl RequestSigner { // Build resource string let decoded_path = percent_encoding::percent_decode_str(path).decode_utf8_lossy(); - let resource_path = format!("/{}{}", self.bucket, decoded_path); + let authority = req.uri.authority().map(|v| v.as_str()).unwrap_or(""); + let is_virtual_host = authority.starts_with(&format!("{}.", self.bucket)); + + let resource_path = if is_virtual_host { + format!("/{}{}", self.bucket, decoded_path) + } else { + // Path-style addressing already includes bucket in request path: http://endpoint//, do not repeat + decoded_path.to_string() + }; if query_pairs.is_empty() { resource_path