Project

General

Profile

[Solved] mod_webdav: Etag in response differs between PROPFIND and GET

Added by ethoms over 6 years ago

The 'Etag' returned in a response to a GET request does not match the 'getetag' returned in a response to a PROPFIND.

For example, a file called 'test.txt' containing the text "hello world" has a PROPFIND response of '<D:getetag>858-12-1500674166</D:getetag>', whilst the GET has a response of 'ETag: "1726050339"'.

Context: the PROPFIND is used to list a collection whilst browsing in a file manager. The GET is used to download a copy of a file, cache it locally and open/edit it.

The problem is that davfs2 relies heavily on caching to ensure it has acceptable performance. It seems davfs2 uses the 'Etag' property of a GET response when committing the file to local cache, yet uses the 'getetag' property of a PROPFIND response when deciding if the file in cache is up-to-date. Thus, since they don't match, the file gets downloaded to cache every time FUSE needs to access the file. Even when just doing a right-click->properties in the file manager.

Worth noting that the configuration settings 'etag.use-inode', 'etag.use-mtime' and 'etag.use-size' all alter the value of both the 'Etag' and the 'getetag'. However, it seems the algorithm to determine the etag is different between 'PROPFIND' and 'GET'.

Lighttpd version: 1.4.45
OS environment: FreeBSD 10.3-RELEASE-p18 amd64


Replies (3)

RE: mod_webdav: Etag in response differs between PROPFIND and GET - Added by gstrauss over 6 years ago

Thanks for reporting. From a quick look, this is a bug in mod_webdav. This patch should fix it for you:

--- a/src/mod_webdav.c
+++ b/src/mod_webdav.c
@@ -978,6 +978,7 @@ static int webdav_get_live_property(server *srv, connection *con, handler_ctx *h
                        found = 1;
                } else if (0 == strcmp(prop_name, "getetag")) {
                        etag_create(con->physical.etag, &sce->st, con->etag_flags);
+                       etag_mutate(con->physical.etag, con->physical.etag);
                        buffer_append_string_len(b, CONST_STR_LEN("<D:getetag>"));
                        buffer_append_string_buffer(b, con->physical.etag);
                        buffer_append_string_len(b, CONST_STR_LEN("</D:getetag>"));

RE: [Solved] mod_webdav: Etag in response differs between PROPFIND and GET - Added by gstrauss over 6 years ago

(Patch committed and will be part of upcoming release of lighttpd 1.4.46)

RE: [Solved] mod_webdav: Etag in response differs between PROPFIND and GET - Added by ethoms over 6 years ago

Thanks gstrauss. Impressive response time!

I tested the patch above and it fixes the issue in davfs2 just fine.

I look forward to the next release in the FreeBSD ports tree.

    (1-3/3)