eclipse-californium / californium

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

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

Closed Woguagua closed 1 month ago

Woguagua commented 1 month 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 1 month 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 1 month 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,