org.eclipse.californium.core.coap.Request.getOptions()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(271)

本文整理了Java中org.eclipse.californium.core.coap.Request.getOptions方法的一些代码示例,展示了Request.getOptions的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getOptions方法的具体详情如下:
包路径:org.eclipse.californium.core.coap.Request
类名称:Request
方法名:getOptions

Request.getOptions介绍

暂无

代码示例

代码示例来源:origin: eclipse/leshan

  1. @Override
  2. public boolean accept(ObserveRelation relation) {
  3. String relationURI = relation.getExchange().getRequest().getOptions().getUriPathString();
  4. boolean result = relationURI.equals(notifyURI);
  5. if (LOG.isTraceEnabled()) {
  6. LOG.trace("observe " + relationURI + " / " + notifyURI + ": " + result);
  7. }
  8. return result;
  9. }

代码示例来源:origin: eclipse/californium

  1. public CC23(String serverURI) {
  2. super(CC23.class.getSimpleName());
  3. Request request = new Request(Code.PUT, Type.CON);
  4. // request.setIfNoneMatch();
  5. request.getOptions().setIfNoneMatch(true);
  6. request.setPayload("TD_COAP_CORE_23 Part A");
  7. request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
  8. executeRequest(request, serverURI, RESOURCE_URI);
  9. }

代码示例来源:origin: eclipse/californium

  1. public CL09(String serverURI) {
  2. super(CL09.class.getSimpleName());
  3. // create the request
  4. Request request = new Request(Code.GET, Type.CON);
  5. request.getOptions().addUriQuery(URI_QUERY);
  6. executeRequest(request, serverURI, RESOURCE_URI);
  7. }

代码示例来源:origin: eclipse/californium

  1. public CC20(String serverURI) {
  2. super(CC20.class.getSimpleName());
  3. // create the request
  4. Request request = new Request(Code.GET, Type.CON);
  5. // request.setOption(new Option(MediaTypeRegistry.TEXT_PLAIN,
  6. // OptionNumberRegistry.ACCEPT));
  7. request.getOptions().setAccept(MediaTypeRegistry.TEXT_PLAIN);
  8. // set the parameters and execute the request
  9. executeRequest(request, serverURI, RESOURCE_URI);
  10. }

代码示例来源:origin: eclipse/californium

  1. private static void earlyBlock2Negotiation(final Exchange exchange, final Request request) {
  2. // Call this method when a request has completely arrived (might have
  3. // been sent in one piece without blockwise).
  4. BlockOption block2 = request.getOptions().getBlock2();
  5. if (block2 != null) {
  6. BlockwiseStatus status2 = new BlockwiseStatus(request.getOptions().getContentFormat(), block2.getNum(), block2.getSzx());
  7. LOGGER.log(Level.FINE, "Request with early block negotiation {0}. Create and set new Block2 status: {1}", new Object[]{block2, status2});
  8. exchange.setResponseBlockStatus(status2);
  9. }
  10. }

代码示例来源:origin: eclipse/californium

  1. public CB01(String serverURI) {
  2. super(CB01.class.getSimpleName());
  3. Request request = Request.newGet();
  4. request.getOptions().setBlock2(BlockOption.size2Szx(64), false, 0);
  5. // set the parameters and execute the request
  6. executeRequest(request, serverURI, "/large");
  7. }

代码示例来源:origin: eclipse/californium

  1. public CB05(String serverURI) {
  2. super(CB05.class.getSimpleName());
  3. Request request = Request.newPost();
  4. request.setPayload(data);
  5. request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
  6. // set the parameters and execute the request
  7. executeRequest(request, serverURI, "/large-post");
  8. }

代码示例来源:origin: eclipse/californium

  1. public CC04(String serverURI) {
  2. super(CC04.class.getSimpleName());
  3. // create the request
  4. Request request = Request.newPost();
  5. // add payload
  6. request.setPayload("TD_COAP_CORE_04");
  7. request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
  8. // set the parameters and execute the request
  9. executeRequest(request, serverURI, RESOURCE_URI);
  10. }

代码示例来源:origin: eclipse/californium

  1. public CC19(String serverURI) {
  2. super(CC19.class.getSimpleName());
  3. // create the request
  4. Request request = new Request(Code.POST, Type.CON);
  5. // add payload
  6. request.setPayload("TD_COAP_CORE_19");
  7. request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
  8. // set the parameters and execute the request
  9. executeRequest(request, serverURI, RESOURCE_URI);
  10. }

代码示例来源:origin: eclipse/californium

  1. public CB04(String serverURI) {
  2. super(CB04.class.getSimpleName());
  3. Request request = Request.newPost();
  4. request.setPayload(data);
  5. request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
  6. // set the parameters and execute the request
  7. executeRequest(request, serverURI, "/large-create");
  8. // TODO: verify resource creation (optional): send GET request to
  9. // location path of response
  10. }

代码示例来源:origin: eclipse/californium

  1. public CC08(String serverURI) {
  2. super(CC08.class.getSimpleName());
  3. // create the request
  4. Request request = new Request(Code.POST);
  5. request.setConfirmable(false);
  6. // add payload
  7. request.setPayload("TD_COAP_CORE_08");
  8. request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
  9. // set the parameters and execute the request
  10. executeRequest(request, serverURI, RESOURCE_URI);
  11. }

代码示例来源:origin: eclipse/californium

  1. public void set(final Request request) {
  2. Object obj = storage.get(var);
  3. assertThat("Object stored under variable " + var + " is not a byte array", obj,
  4. is(instanceOf(byte[].class)));
  5. request.getOptions().addETag((byte[]) obj);
  6. }
  7. });

代码示例来源:origin: eclipse/leshan

  1. @Override
  2. public void visit(DeregisterRequest request) {
  3. coapRequest = Request.newDelete();
  4. buildRequestSettings();
  5. coapRequest.getOptions().setUriPath(request.getRegistrationId());
  6. }

代码示例来源:origin: eclipse/californium

  1. public void check(Request request) {
  2. assertEquals(path, request.getOptions().getUriPathString());
  3. print("Correct URI path: " + path);
  4. }
  5. });

代码示例来源:origin: eclipse/leshan

  1. @Override
  2. public void visit(ReadRequest request) {
  3. coapRequest = Request.newGet();
  4. if (request.getContentFormat() != null)
  5. coapRequest.getOptions().setAccept(request.getContentFormat().getCode());
  6. setTarget(coapRequest, request.getPath());
  7. }

代码示例来源:origin: eclipse/californium

  1. @Test
  2. public void testSetOptionsSetsUriHostOption() {
  3. Request req = Request.newGet();
  4. req.setDestination(InetAddress.getLoopbackAddress());
  5. req.setOptions(URI.create("coap://iot.eclipse.org"));
  6. assertThat(req.getDestinationPort(), is(CoAP.DEFAULT_COAP_PORT));
  7. assertThat(req.getOptions().getUriHost(), is("iot.eclipse.org"));
  8. }

代码示例来源:origin: eclipse/californium

  1. private void startBlockwiseUpload(final Exchange exchange, final Request request) {
  2. BlockwiseStatus status = findRequestBlockStatus(exchange, request);
  3. final Request block = getNextRequestBlock(request, status);
  4. // indicate overall body size to peer
  5. block.getOptions().setSize1(request.getPayloadSize());
  6. exchange.setRequestBlockStatus(status);
  7. exchange.setCurrentRequest(block);
  8. lower().sendRequest(exchange, block);
  9. }

代码示例来源:origin: eclipse/leshan

  1. @Override
  2. public void visit(BootstrapWriteRequest request) {
  3. coapRequest = Request.newPut();
  4. coapRequest.setConfirmable(true);
  5. ContentFormat format = request.getContentFormat();
  6. coapRequest.getOptions().setContentFormat(format.getCode());
  7. coapRequest.setPayload(encoder.encode(request.getNode(), format, request.getPath(), model));
  8. setTarget(coapRequest, request.getPath());
  9. }

代码示例来源:origin: eclipse/californium

  1. @Test
  2. public void testSetURIDoesNotSetUriHostOptionForIp6Address() {
  3. // use www.google.com's IPv6 address
  4. Request req = Request.newGet().setURI("coap://[2a00:1450:4001:817::2003]");
  5. assertNull(req.getOptions().getUriHost());
  6. }

代码示例来源:origin: eclipse/californium

  1. private static Request newBlockwiseRequest(final int bodySize, final int blockSize) {
  2. Request request = Request.newPut();
  3. request.getOptions().setBlock1(BlockOption.size2Szx(blockSize), true, 0).setSize1(bodySize);
  4. request.setPayload(generateRandomPayload(blockSize));
  5. return request;
  6. }
  7. }

相关文章