Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Automatic content negotiation #3

Open
mkovatsc opened this issue Jun 10, 2014 · 1 comment
Open

Automatic content negotiation #3

mkovatsc opened this issue Jun 10, 2014 · 1 comment

Comments

@mkovatsc
Copy link

Content-Format and Accept handling is currently fully up to the resource implementer. Californium could provide an Accept option check before delivering requests or check the Content-Format after a request was processed and could automatically react with 4.06 Not Acceptable.

This could be added as Layer for the CoapStack.

martinlanter added a commit to martinlanter/californium that referenced this issue Jul 31, 2014
…Added an interface

AcceptSupport and a default implementation AcceptDefaultSupport and a
JUnit test. A CoapResource now has an AcceptSupport object. If a
resource defines some specific formats that are being accepted and the
request asks for another format, the resource automatically responds
with a 4.06.
@martinlanter
Copy link
Contributor

I have implemented a proposal for this issue (https://github.com/Lanterm/californium/tree/accept-and-etag). I have added an interface AcceptSupport and a default implementation AcceptDefaultSupport. Each resource has such an object. By default, the support object lets any request pass and it will be up to the code in handleGET() to process it. This is exactly the behavior as of now. However, if the resource calls for instance getAcceptSupport().addAcceptable(MediaTypeRegistry.APPLICATION_XML);, the support object will check for the accept options of requests. If the accept option asks for a supported format, it passes. Otherwise, the resource automatically responds with a 4.06 and does NOT invoke handleGET(). With this mechanism, the developer is able to prevent requests with unsupported accept options from reaching the handleGET() method with minimal effort.

I did not choose to make this a layer in the CoapStack because it is not yet clear at this stage which resource is going to be the target, and therefore which content format it supports.

martinlanter added a commit to martinlanter/californium that referenced this issue Aug 3, 2014
…Added an interface

AcceptSupport and a default implementation AcceptDefaultSupport and a
JUnit test. A CoapResource now has an AcceptSupport object. If a
resource defines some specific formats that are being accepted and the
request asks for another format, the resource automatically responds
with a 4.06.
martinlanter added a commit to martinlanter/californium that referenced this issue Aug 3, 2014
…Added an interface

AcceptSupport and a default implementation AcceptDefaultSupport and a
JUnit test. A CoapResource now has an AcceptSupport object. If a
resource defines some specific formats that are being accepted and the
request asks for another format, the resource automatically responds
with a 4.06.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants