eclipse-californium / californium

CoAP/DTLS Java Implementation
https://www.eclipse.org/californium/
Other
730 stars 367 forks source link

OptionValue is empty when client post a request with MediaTypeRegistry.TEXT_PLAIN #2260

Closed Woguagua closed 4 months ago

Woguagua commented 4 months ago

I am using Californium to build a CoAP client in my computer. And I use the API Californium provided as follows: CoapResponse response = client.post(payload, MediaTypeRegistry.TEXT_PLAIN); However, when I receive this request and decode it with my server built by my own application, I find that the option length of the option "Content-Format" is 0, and the corresponding option value is empty. As the RFC7252 defines, the option value should be 0 for "text/plain", not empty.

boaks commented 4 months ago

RFC 7252, 3.2 Option Value Formats

uint:  ...
             For example, the number 0 is
             represented with an empty option value (a zero-length
             sequence of bytes)
boaks commented 4 months ago

@Woguagua

As the RFC7252 defines, the option value should be 0 for "text/plain", not empty.

As in my comment, RFC 7252 explicitly defines, that the value 0 is an empty option value. Therefore the encoding used by Californium complies with the spec. If you've implemented your server on your own, maybe you adapt it. If it's a product or project of someone else, maybe you forward this information to them,

Woguagua commented 2 months ago

Thanks for your reply

boaks commented 2 months ago

You're welcome.