Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding options to responses #20

Open
erkki opened this issue Jun 25, 2018 · 5 comments
Open

Adding options to responses #20

erkki opened this issue Jun 25, 2018 · 5 comments

Comments

@erkki
Copy link

erkki commented Jun 25, 2018

I'm having a hard time figuring out how to add options to responses within the resource callbacks. Such as Location-Path/Location-Query in a response to a POST that creates a resource.
I'm looking at adding options as parameters to the callback methods but wondering if I'm missing something.

@gotthardp
Copy link
Owner

Hmm. I don't think this is possible with the current implementation.

@erkki
Copy link
Author

erkki commented Jun 26, 2018

Thanks for the quick reply :)

@erkki
Copy link
Author

erkki commented Jun 26, 2018

For background, this is part of the CoAP spec (and necessary to implement OMA LwM2M):

5.8.2. POST

The POST method requests that the representation enclosed in the
request be processed. The actual function performed by the POST
method is determined by the origin server and dependent on the target
resource. It usually results in a new resource being created or the
target resource being updated.

If a resource has been created on the server, the response returned
by the server SHOULD have a 2.01 (Created) Response Code and SHOULD
include the URI of the new resource in a sequence of one or more
Location-Path and/or Location-Query Options (Section 5.10.7). If the
POST succeeds but does not result in a new resource being created on
the server, the response SHOULD have a 2.04 (Changed) Response Code.
If the POST succeeds and results in the target resource being
deleted, the response SHOULD have a 2.02 (Deleted) Response Code.
POST is neither safe nor idempotent.

@gotthardp
Copy link
Owner

I could implement it if you help me with the analysis. I haven't worked with CoAP for few years, so I forgot almost everything.
The question I have is whether each resource shall be associated with a location, or whether the location shall be set in the message only. And the second question is whether the location shall be set automatically based on the request URI or whether the resource handler shall be able to set the location to whatever value it wants.

@erkki
Copy link
Author

erkki commented Jun 26, 2018

Sure, I'm just getting familiar with CoAP but I'll try :).

The question I have is whether each resource shall be associated with a location, or whether the location shall be set in the message only.

To me it seems more reasonable that it's in the message only, given that
a) not all resources necessarily associate with a location and
b) Location was just an example of setting options but one should be able to set other options in the response, too (https://tools.ietf.org/html/rfc7252#section-5.4)

And the second question is whether the location shall be set automatically based on the request URI or whether the resource handler shall be able to set the location to whatever value it wants.

Probably the latter, it's still up to the user/server to define semantics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants