webdav-client-python icon indicating copy to clipboard operation
webdav-client-python copied to clipboard

etag support

Open wochinge opened this issue 9 years ago • 0 comments

Hi,

I suggest to add support for the etag field. The change would be just a few lines in client.py:

find_attributes = {
    'created': ".//{DAV:}creationdate",
    'name': ".//{DAV:}displayname",
    'size': ".//{DAV:}getcontentlength",
    'modified': ".//{DAV:}getlastmodified",
    'etag': ".//{DAV:}getetag"  # new
}

I'd further add the following to remove the quotes around the etag (without this, it would be something link '"etag"'. I suggest to use the try / except - pattern as most servers are supporting the etag-field, and therefore this is approach is usually faster.

for (name, value) in find_attributes.items():
    info[name] = resp.findtext(value)

# new
try:
    info['etag'] = info['etag'][1:-1]  # remove quotes from etag
except KeyError:
    pass

Cheers Tobias

wochinge avatar Dec 08 '16 16:12 wochinge