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 079d836d41 test(integrations/dav-server): cover Fs responses without 
ETags (#9079)
079d836d41 is described below

commit 079d836d410dc63554a59f4f649d4fc9243e5a58
Author: mola <[email protected]>
AuthorDate: Thu Nov 26 03:36:02 2026 +0800

    test(integrations/dav-server): cover Fs responses without ETags (#9079)
    
    * fix(integrations/dav-server): derive an ETag when the backend reports none
    
    OpendalMetaData overrides DavMetaData::etag and returned None when the
    OpenDAL metadata had no ETag. That also disabled dav-server's default,
    which derives an ETag from the length and modification time. A server
    on a backend without ETags, such as fs, sent no ETag in GET, HEAD or
    PROPFIND responses, so clients could not use If-Match or If-None-Match
    with a real ETag.
    
    Fall back to the same derivation when the backend has no ETag. Invalid
    backend ETags are still dropped as before.
    
    
    * fix(integrations/dav-server): send no ETag when the backend reports none
    
    A tag derived from length and microsecond mtime stays the same when
    same-length content is replaced within one microsecond, so a conditional
    GET with the old tag returns a stale 304. Drop the derived fallback and
    send no ETag when the backend reports none. Native ETags are unchanged.
    
    Add an HTTP regression test on the Fs loopback: after a same-length
    replacement with the mtime pinned, the GET carries no ETag and a
    conditional GET with the tag the old derivation would have produced
    returns the new bytes.
    
    * test(integrations/dav-server): cover Fs responses without ETags
    
    Keep a loopback check for PUT, HEAD, and GET on Fs. When OpenDAL supplies 
only a modification time, the adapter must not synthesize an ETag. The existing 
native ETag tests cover normalization separately.
    
    ---------
    
    Co-authored-by: Mola-maker <[email protected]>
    Co-authored-by: Xuanwo <[email protected]>
---
 integrations/dav-server/tests/webdav_loopback.rs | 28 ++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/integrations/dav-server/tests/webdav_loopback.rs 
b/integrations/dav-server/tests/webdav_loopback.rs
index 6474ace460..a79fbba90d 100644
--- a/integrations/dav-server/tests/webdav_loopback.rs
+++ b/integrations/dav-server/tests/webdav_loopback.rs
@@ -554,3 +554,31 @@ async fn sabredav_patch_append_and_unsupported_ranges() -> 
Result<()> {
     assert_eq!(response.body().as_ref(), b"cde");
     Ok(())
 }
+
+#[tokio::test]
+async fn fs_responses_omit_etag_when_only_last_modified_is_available() -> 
Result<()> {
+    let dav = WebDav::new().await?;
+    let put = dav
+        .send(
+            dav.request("PUT", "/file.txt"),
+            b"hello",
+            StatusCode::CREATED,
+        )
+        .await?;
+    assert!(
+        !put.headers().contains_key(header::ETAG),
+        "PUT emitted a synthetic ETag"
+    );
+
+    for method in ["HEAD", "GET"] {
+        let response = dav
+            .send(dav.request(method, "/file.txt"), b"", StatusCode::OK)
+            .await?;
+        assert!(response.headers().contains_key(header::LAST_MODIFIED));
+        assert!(
+            !response.headers().contains_key(header::ETAG),
+            "{method} emitted a synthetic ETag"
+        );
+    }
+    Ok(())
+}

Reply via email to