本文整理了Java中org.eclipse.californium.core.coap.Request.getOptions
方法的一些代码示例,展示了Request.getOptions
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getOptions
方法的具体详情如下:
包路径:org.eclipse.californium.core.coap.Request
类名称:Request
方法名:getOptions
暂无
代码示例来源:origin: eclipse/leshan
@Override
public boolean accept(ObserveRelation relation) {
String relationURI = relation.getExchange().getRequest().getOptions().getUriPathString();
boolean result = relationURI.equals(notifyURI);
if (LOG.isTraceEnabled()) {
LOG.trace("observe " + relationURI + " / " + notifyURI + ": " + result);
}
return result;
}
代码示例来源:origin: eclipse/californium
public CC23(String serverURI) {
super(CC23.class.getSimpleName());
Request request = new Request(Code.PUT, Type.CON);
// request.setIfNoneMatch();
request.getOptions().setIfNoneMatch(true);
request.setPayload("TD_COAP_CORE_23 Part A");
request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
executeRequest(request, serverURI, RESOURCE_URI);
}
代码示例来源:origin: eclipse/californium
public CL09(String serverURI) {
super(CL09.class.getSimpleName());
// create the request
Request request = new Request(Code.GET, Type.CON);
request.getOptions().addUriQuery(URI_QUERY);
executeRequest(request, serverURI, RESOURCE_URI);
}
代码示例来源:origin: eclipse/californium
public CC20(String serverURI) {
super(CC20.class.getSimpleName());
// create the request
Request request = new Request(Code.GET, Type.CON);
// request.setOption(new Option(MediaTypeRegistry.TEXT_PLAIN,
// OptionNumberRegistry.ACCEPT));
request.getOptions().setAccept(MediaTypeRegistry.TEXT_PLAIN);
// set the parameters and execute the request
executeRequest(request, serverURI, RESOURCE_URI);
}
代码示例来源:origin: eclipse/californium
private static void earlyBlock2Negotiation(final Exchange exchange, final Request request) {
// Call this method when a request has completely arrived (might have
// been sent in one piece without blockwise).
BlockOption block2 = request.getOptions().getBlock2();
if (block2 != null) {
BlockwiseStatus status2 = new BlockwiseStatus(request.getOptions().getContentFormat(), block2.getNum(), block2.getSzx());
LOGGER.log(Level.FINE, "Request with early block negotiation {0}. Create and set new Block2 status: {1}", new Object[]{block2, status2});
exchange.setResponseBlockStatus(status2);
}
}
代码示例来源:origin: eclipse/californium
public CB01(String serverURI) {
super(CB01.class.getSimpleName());
Request request = Request.newGet();
request.getOptions().setBlock2(BlockOption.size2Szx(64), false, 0);
// set the parameters and execute the request
executeRequest(request, serverURI, "/large");
}
代码示例来源:origin: eclipse/californium
public CB05(String serverURI) {
super(CB05.class.getSimpleName());
Request request = Request.newPost();
request.setPayload(data);
request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
// set the parameters and execute the request
executeRequest(request, serverURI, "/large-post");
}
代码示例来源:origin: eclipse/californium
public CC04(String serverURI) {
super(CC04.class.getSimpleName());
// create the request
Request request = Request.newPost();
// add payload
request.setPayload("TD_COAP_CORE_04");
request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
// set the parameters and execute the request
executeRequest(request, serverURI, RESOURCE_URI);
}
代码示例来源:origin: eclipse/californium
public CC19(String serverURI) {
super(CC19.class.getSimpleName());
// create the request
Request request = new Request(Code.POST, Type.CON);
// add payload
request.setPayload("TD_COAP_CORE_19");
request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
// set the parameters and execute the request
executeRequest(request, serverURI, RESOURCE_URI);
}
代码示例来源:origin: eclipse/californium
public CB04(String serverURI) {
super(CB04.class.getSimpleName());
Request request = Request.newPost();
request.setPayload(data);
request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
// set the parameters and execute the request
executeRequest(request, serverURI, "/large-create");
// TODO: verify resource creation (optional): send GET request to
// location path of response
}
代码示例来源:origin: eclipse/californium
public CC08(String serverURI) {
super(CC08.class.getSimpleName());
// create the request
Request request = new Request(Code.POST);
request.setConfirmable(false);
// add payload
request.setPayload("TD_COAP_CORE_08");
request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
// set the parameters and execute the request
executeRequest(request, serverURI, RESOURCE_URI);
}
代码示例来源:origin: eclipse/californium
public void set(final Request request) {
Object obj = storage.get(var);
assertThat("Object stored under variable " + var + " is not a byte array", obj,
is(instanceOf(byte[].class)));
request.getOptions().addETag((byte[]) obj);
}
});
代码示例来源:origin: eclipse/leshan
@Override
public void visit(DeregisterRequest request) {
coapRequest = Request.newDelete();
buildRequestSettings();
coapRequest.getOptions().setUriPath(request.getRegistrationId());
}
代码示例来源:origin: eclipse/californium
public void check(Request request) {
assertEquals(path, request.getOptions().getUriPathString());
print("Correct URI path: " + path);
}
});
代码示例来源:origin: eclipse/leshan
@Override
public void visit(ReadRequest request) {
coapRequest = Request.newGet();
if (request.getContentFormat() != null)
coapRequest.getOptions().setAccept(request.getContentFormat().getCode());
setTarget(coapRequest, request.getPath());
}
代码示例来源:origin: eclipse/californium
@Test
public void testSetOptionsSetsUriHostOption() {
Request req = Request.newGet();
req.setDestination(InetAddress.getLoopbackAddress());
req.setOptions(URI.create("coap://iot.eclipse.org"));
assertThat(req.getDestinationPort(), is(CoAP.DEFAULT_COAP_PORT));
assertThat(req.getOptions().getUriHost(), is("iot.eclipse.org"));
}
代码示例来源:origin: eclipse/californium
private void startBlockwiseUpload(final Exchange exchange, final Request request) {
BlockwiseStatus status = findRequestBlockStatus(exchange, request);
final Request block = getNextRequestBlock(request, status);
// indicate overall body size to peer
block.getOptions().setSize1(request.getPayloadSize());
exchange.setRequestBlockStatus(status);
exchange.setCurrentRequest(block);
lower().sendRequest(exchange, block);
}
代码示例来源:origin: eclipse/leshan
@Override
public void visit(BootstrapWriteRequest request) {
coapRequest = Request.newPut();
coapRequest.setConfirmable(true);
ContentFormat format = request.getContentFormat();
coapRequest.getOptions().setContentFormat(format.getCode());
coapRequest.setPayload(encoder.encode(request.getNode(), format, request.getPath(), model));
setTarget(coapRequest, request.getPath());
}
代码示例来源:origin: eclipse/californium
@Test
public void testSetURIDoesNotSetUriHostOptionForIp6Address() {
// use www.google.com's IPv6 address
Request req = Request.newGet().setURI("coap://[2a00:1450:4001:817::2003]");
assertNull(req.getOptions().getUriHost());
}
代码示例来源:origin: eclipse/californium
private static Request newBlockwiseRequest(final int bodySize, final int blockSize) {
Request request = Request.newPut();
request.getOptions().setBlock1(BlockOption.size2Szx(blockSize), true, 0).setSize1(bodySize);
request.setPayload(generateRandomPayload(blockSize));
return request;
}
}
内容来源于网络,如有侵权,请联系作者删除!