@Test public void testPrepareEOptions() { OptionSet eOptions = new OptionSet(); eOptions.setOscore(oscore); eOptions.setAccept(accept); OptionSet trimmed = OptionJuggle.prepareEoptions(eOptions); assertNull(trimmed.getOscore()); assertEquals(accept, trimmed.getAccept()); }
public static OptionSet prepareEoptions(OptionSet options) { OptionSet ret = new OptionSet(); for (Option o : options.asSortedList()) { switch (o.getNumber()) { case OptionNumberRegistry.URI_HOST: case OptionNumberRegistry.URI_PORT: case OptionNumberRegistry.PROXY_SCHEME: case OptionNumberRegistry.OSCORE: break; case OptionNumberRegistry.PROXY_URI: String proxyUri = o.getStringValue(); proxyUri = proxyUri.replace("coap: proxyUri = proxyUri.replace("coaps: int i = proxyUri.indexOf('/'); if (i >= 0) { proxyUri = proxyUri.substring(i + 1, proxyUri.length()); } else { break; } i = proxyUri.indexOf("?"); String uriPath = proxyUri; String uriQuery = null; if (i >= 0) { uriPath = proxyUri.substring(0, i); uriQuery = proxyUri.substring(i + 1, proxyUri.length()); } if (uriPath != null) { ret.setUriPath(uriPath); } if (uriQuery != null) { String[] uriQueries = uriQuery.split("&"); for (int idx = 0; idx < uriQueries.length; idx++) { ret.setUriQuery(uriQueries[idx]); } } break; default: ret.addOption(o); } } return ret; }
OptionJuggle { public static OptionSet prepareEoptions(OptionSet options) { OptionSet ret = new OptionSet(); for (Option o : options.asSortedList()) { switch (o.getNumber()) { case OptionNumberRegistry.URI_HOST: case OptionNumberRegistry.URI_PORT: case OptionNumberRegistry.PROXY_SCHEME: case OptionNumberRegistry.OSCORE: break; case OptionNumberRegistry.PROXY_URI: String proxyUri = o.getStringValue(); proxyUri = proxyUri.replace("coap: proxyUri = proxyUri.replace("coaps: int i = proxyUri.indexOf('/'); if (i >= 0) { proxyUri = proxyUri.substring(i + 1, proxyUri.length()); } else { break; } i = proxyUri.indexOf("?"); String uriPath = proxyUri; String uriQuery = null; if (i >= 0) { uriPath = proxyUri.substring(0, i); uriQuery = proxyUri.substring(i + 1, proxyUri.length()); } if (uriPath != null) { ret.setUriPath(uriPath); } if (uriQuery != null) { String[] uriQueries = uriQuery.split("&"); for (int idx = 0; idx < uriQueries.length; idx++) { ret.setUriQuery(uriQueries[idx]); } } break; default: ret.addOption(o); } } return ret; } }
OptionJuggle { public static OptionSet prepareEoptions(OptionSet options) { OptionSet ret = new OptionSet(); for (Option o : options.asSortedList()) { switch (o.getNumber()) { case OptionNumberRegistry.URI_HOST: case OptionNumberRegistry.URI_PORT: case OptionNumberRegistry.PROXY_SCHEME: case OptionNumberRegistry.OSCORE: break; case OptionNumberRegistry.PROXY_URI: String proxyUri = o.getStringValue(); proxyUri = proxyUri.replace("coap: proxyUri = proxyUri.replace("coaps: int i = proxyUri.indexOf('/'); if (i >= 0) { proxyUri = proxyUri.substring(i + 1, proxyUri.length()); } else { break; } i = proxyUri.indexOf("?"); String uriPath = proxyUri; String uriQuery = null; if (i >= 0) { uriPath = proxyUri.substring(0, i); uriQuery = proxyUri.substring(i + 1, proxyUri.length()); } if (uriPath != null) { ret.setUriPath(uriPath); } if (uriQuery != null) { String[] uriQueries = uriQuery.split("&"); for (int idx = 0; idx < uriQueries.length; idx++) { ret.setUriQuery(uriQueries[idx]); } } break; default: ret.addOption(o); } } return ret; }  }
OptionJuggle { public static OptionSet prepareEoptions(OptionSet options) { OptionSet ret = new OptionSet(); for (Option o : options.asSortedList()) { switch (o.getNumber()) { case OptionNumberRegistry.URI_HOST: case OptionNumberRegistry.URI_PORT: case OptionNumberRegistry.PROXY_SCHEME: case OptionNumberRegistry.OSCORE: break; case OptionNumberRegistry.PROXY_URI: String proxyUri = o.getStringValue(); proxyUri = proxyUri.replace("coap: proxyUri = proxyUri.replace("coaps: int i = proxyUri.indexOf('/'); if (i >= 0) { proxyUri = proxyUri.substring(i + 1, proxyUri.length()); } else { break; } i = proxyUri.indexOf("?"); String uriPath = proxyUri; String uriQuery = null; if (i >= 0) { uriPath = proxyUri.substring(0, i); uriQuery = proxyUri.substring(i + 1, proxyUri.length()); } if (uriPath != null) { ret.setUriPath(uriPath); } if (uriQuery != null) { String[] uriQueries = uriQuery.split("&"); for (int idx = 0; idx < uriQueries.length; idx++) { ret.setUriQuery(uriQueries[idx]); } } break; default: ret.addOption(o); } } return ret; }  static OptionSet prepareUoptions(OptionSet options); static OptionSet prepareEoptions(OptionSet options); static OptionSet discardEOptions(OptionSet optionSet); static Request setFakeCodeRequest(Request request); static Request setRealCodeRequest(Request request, Code realCode); static Response setFakeCodeResponse(Response response); static Response setRealCodeResponse(Response response, ResponseCode realCode); static OptionSet merge(OptionSet eOptions, OptionSet uOptions); }
OptionJuggle { public static OptionSet prepareEoptions(OptionSet options) { OptionSet ret = new OptionSet(); for (Option o : options.asSortedList()) { switch (o.getNumber()) { case OptionNumberRegistry.URI_HOST: case OptionNumberRegistry.URI_PORT: case OptionNumberRegistry.PROXY_SCHEME: case OptionNumberRegistry.OSCORE: break; case OptionNumberRegistry.PROXY_URI: String proxyUri = o.getStringValue(); proxyUri = proxyUri.replace("coap: proxyUri = proxyUri.replace("coaps: int i = proxyUri.indexOf('/'); if (i >= 0) { proxyUri = proxyUri.substring(i + 1, proxyUri.length()); } else { break; } i = proxyUri.indexOf("?"); String uriPath = proxyUri; String uriQuery = null; if (i >= 0) { uriPath = proxyUri.substring(0, i); uriQuery = proxyUri.substring(i + 1, proxyUri.length()); } if (uriPath != null) { ret.setUriPath(uriPath); } if (uriQuery != null) { String[] uriQueries = uriQuery.split("&"); for (int idx = 0; idx < uriQueries.length; idx++) { ret.setUriQuery(uriQueries[idx]); } } break; default: ret.addOption(o); } } return ret; }  static OptionSet prepareUoptions(OptionSet options); static OptionSet prepareEoptions(OptionSet options); static OptionSet discardEOptions(OptionSet optionSet); static Request setFakeCodeRequest(Request request); static Request setRealCodeRequest(Request request, Code realCode); static Response setFakeCodeResponse(Response response); static Response setRealCodeResponse(Response response, ResponseCode realCode); static OptionSet merge(OptionSet eOptions, OptionSet uOptions);  }