Describe encoding of Etag

This commit is contained in:
Unrud 2016-09-04 12:52:29 +02:00
parent b85fc5bed6
commit 8d5f2ded42

View File

@ -100,7 +100,11 @@ def load(configuration, logger):
def get_etag(text): def get_etag(text):
"""Etag from collection or item.""" """Etag from collection or item.
Encoded as quoted-string (see RFC 2616).
"""
etag = md5() etag = md5()
etag.update(text.encode("utf-8")) etag.update(text.encode("utf-8"))
return '"%s"' % etag.hexdigest() return '"%s"' % etag.hexdigest()
@ -205,6 +209,7 @@ class Item:
@property @property
def etag(self): def etag(self):
"""Encoded as quoted-string (see RFC 2616)."""
return get_etag(self.serialize()) return get_etag(self.serialize())
@ -262,6 +267,7 @@ class BaseCollection:
@property @property
def etag(self): def etag(self):
"""Encoded as quoted-string (see RFC 2616)."""
return get_etag(self.serialize()) return get_etag(self.serialize())
@classmethod @classmethod