/** * Sets the complete relative Uri-Path. * Returns the current OptionSet object for a fluent API. * @param path the Uri-Path to set * @return this OptionSet */ public OptionSet setUriPath(String path) { final String slash = "/"; // remove leading slash if (path.startsWith(slash)) { path = path.substring(slash.length()); } clearUriPath(); for (String segment : path.split(slash)) { // empty path segments are allowed (e.g., /test vs /test/) addUriPath(segment); } return this; }
/** * Sets the complete relative Uri-Path. * Returns the current OptionSet object for a fluent API. * @param path the Uri-Path to set * @return this OptionSet */ public OptionSet setUriPath(String path) { final String slash = "/"; // remove leading slash if (path.startsWith(slash)) { path = path.substring(slash.length()); } clearUriPath(); for (String segment : path.split(slash)) { // empty path segments are allowed (e.g., /test vs /test/) addUriPath(segment); } return this; }
incomingCoapRequest.getOptions().clearUriPath();; // HACK
incomingRequest.getOptions().clearUriPath();
public Set<WebLink> discover(String query) { Request discover = newGet(); discover.setURI(uri); // for scheme and authority, but then remove path and query discover.getOptions().clearUriPath().clearUriQuery().setUriPath("/.well-known/core"); if (query!=null) { discover.getOptions().setUriQuery(query); } CoapResponse links = synchronous(discover); // if no response, return null (e.g., timeout) if (links == null) { return null; } // check if Link Format if (links.getOptions().getContentFormat()!=MediaTypeRegistry.APPLICATION_LINK_FORMAT) return Collections.emptySet(); // parse and return return LinkFormat.parse(links.getResponseText()); }
public Set<WebLink> discover(String query) { Request discover = Request.newGet(); discover.setURI(uri); // for scheme and authority, but then remove path and query discover.getOptions().clearUriPath().clearUriQuery().setUriPath("/.well-known/core"); if (query!=null) { discover.getOptions().setUriQuery(query); } CoapResponse links = synchronous(discover); // if no response, return null (e.g., timeout) if (links == null) { return null; } // check if Link Format if (links.getOptions().getContentFormat()!=MediaTypeRegistry.APPLICATION_LINK_FORMAT) return Collections.emptySet(); // parse and return return LinkFormat.parse(links.getResponseText()); }
options.removeBlock1(); options.removeBlock2(); options.clearUriPath(); options.clearUriQuery(); outgoingRequest.setOptions(options);
options.removeUriHost(); options.removeUriPort(); options.clearUriPath(); options.clearUriQuery(); outgoingRequest.setOptions(options);
@Test public void testUriOptions() { OptionSet options = new OptionSet(); options.setUriPath("/foo/bar"); Assert.assertEquals("Uri-Path", "foo/bar", options.getUriPathString()); options.setUriPath("foo/bar"); Assert.assertEquals("Uri-Path", "foo/bar", options.getUriPathString()); options.setUriPath("//foo/bar"); Assert.assertEquals("Uri-Path", "/foo/bar", options.getUriPathString()); options.setUriPath("/foo//bar"); Assert.assertEquals("Uri-Path", "foo//bar", options.getUriPathString()); options.clearUriPath(); options.addUriPath("foo"); options.addUriPath("bar"); Assert.assertEquals("Uri-Path", "foo/bar", options.getUriPathString()); options.clearUriPath(); options.addUriPath("foo"); options.addUriPath(""); options.addUriPath("bar"); Assert.assertEquals("Uri-Path", "foo//bar", options.getUriPathString()); }