Open mkovatsc opened 10 years ago
I have implemented a proposal for this issue (https://github.com/Lanterm/californium/tree/accept-and-etag). I have added an Interface ETagSupport and a default implementation ETagDefaultSupport. A CoapResource (new name for ResourceBase) now holds such an ETagSupport object. If the content changes, the resoource just invokes getETagSupport().nextETag();
. If the resource later handles a request holding ETags, it automatically compares the ETags against the current ETag of the ETagSupport object and if one matches responds with a 2.03 (Valid). Only if no ETag matches, the resource calls it handleGET method.
Add convenience support for ETags to ResourceBase or wherever applicable, so that there is out-of-the-box validation support (GET+ETag -> 2.03 Valid). The developer will need to define a hash method or otherwise register the current ETag for the resource.