Closed sbernard31 closed 1 year ago
Currently empty query value can be placed in such way: field1=value1&field2=&field3=
, so equal sign is needed. Would that work with Leshan?
Nope that does not match the LWM2M specification :grimacing:
See for Q option : /rd?ep={Endpoint Client Name}<={Lifetime}&lwm2m={version}&b={binding}&Q&sms={MSISDN}
Currently I parse UriQuery by myself using :
// TODO remove this class when https://github.com/open-coap/java-coap/issues/45 will be fixed.
public class QueryUtil {
public static Map<String, String> parseUriQuery(String uriQuery) {
if (uriQuery == null || uriQuery.length() == 0) {
return Collections.emptyMap();
}
Map<String, String> result = new LinkedHashMap<>();
String[] params = uriQuery.substring(uriQuery.indexOf('?') + 1).split("&");
for (String prm : params) {
String[] p = prm.split("=", 2);
if (p.length == 2) {
result.put(p[0], p[1]);
} else if (p.length == 1) {
result.put(p[0], null);
} else {
throw new IllegalArgumentException();
}
}
return result;
}
}
for (Entry<String, String> entry : QueryUtil.parseUriQuery(coapRequest.options().getUriQuery())
.entrySet()) {
... ..
}
There is release v6.12.0 that contains implementation for this ticket, can we close it?
Tested with v6.12.0, my integrations tests pass now without my "HACK" :heavy_check_mark:
Thx for adding this :pray:
coapRequest.options().getUriQueryMap()
seems to only support Option in the form of a "key=value" pair. It should also support more simple form like "key" without value.(See more detailed at : https://github.com/open-coap/java-coap/issues/27#issuecomment-1507287371)