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

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

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

Request.newPost介绍

[英]Convenience factory method to construct a POST request and equivalent to new Request(Code.POST);
[中]构造POST请求的便利工厂方法,相当于new Request(Code.POST);

代码示例

代码示例来源:origin: org.opendaylight.iotdm/onem2mbenchmark-impl

  1. public OdlOnem2mCoapRequestPrimitiveBuilder setOperationCreate() {
  2. onem2mRequest.coapRequest = Request.newPost();
  3. return this;
  4. }
  5. public OdlOnem2mCoapRequestPrimitiveBuilder setOperationRetrieve() {

代码示例来源:origin: org.opendaylight.iotdm/onem2m-protocol-coap

  1. @Override
  2. public void sendNotification(String url, String payload) {
  3. Request request = Request.newPost();
  4. request.setURI(url);
  5. request.setPayload(payload);
  6. request.send();
  7. LOG.debug("CoAP: Send notification uri: {}, payload: {}:", url, payload);
  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 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 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: org.eclipse.californium/californium-core

  1. /**
  2. * Sends a POST request with the specified payload and the specified content
  3. * format and invokes the specified handler when a response arrives.
  4. *
  5. * @param handler the Response handler
  6. * @param payload the payload
  7. * @param format the Content-Format
  8. */
  9. public void post(CoapHandler handler, String payload, int format) {
  10. asynchronous(format(Request.newPost().setURI(uri).setPayload(payload), format), handler);
  11. }

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

  1. @Override
  2. public void visit(ExecuteRequest request) {
  3. coapRequest = Request.newPost();
  4. setTarget(coapRequest, request.getPath());
  5. coapRequest.setPayload(request.getParameters());
  6. }

代码示例来源:origin: org.eclipse.californium/californium-core

  1. /**
  2. * Sends a POST request with the specified payload and the specified content
  3. * format and invokes the specified handler when a response arrives.
  4. *
  5. * @param handler the Response handler
  6. * @param payload the payload
  7. * @param format the Content-Format
  8. */
  9. public void post(CoapHandler handler, byte[] payload, int format) {
  10. asynchronous(format(Request.newPost().setURI(uri).setPayload(payload), format), handler);
  11. }

代码示例来源:origin: org.eclipse.californium/californium-core

  1. /**
  2. * Sends a POST request with the specified payload, the specified content
  3. * format and accept and invokes the specified handler when a response
  4. * arrives.
  5. *
  6. * @param handler the Response handler
  7. * @param payload the payload
  8. * @param format the Content-Format
  9. * @param accept the Accept option
  10. */
  11. public void post(CoapHandler handler, String payload, int format, int accept) {
  12. asynchronous(accept(format(Request.newPost().setURI(uri).setPayload(payload), format), accept), handler);
  13. }

代码示例来源:origin: org.eclipse.californium/californium-core

  1. /**
  2. * Sends a POST request with the specified payload, the specified content
  3. * format and accept and invokes the specified handler when a response
  4. * arrives.
  5. *
  6. * @param handler the Response handler
  7. * @param payload the payload
  8. * @param format the Content-Format
  9. * @param accept the Accept option
  10. */
  11. public void post(CoapHandler handler, byte[] payload, int format, int accept) {
  12. asynchronous(accept(format(Request.newPost().setURI(uri).setPayload(payload), format), accept), handler);
  13. }

代码示例来源:origin: org.github.leshan/leshan-client

  1. @Override
  2. public void visit(final BootstrapRequest request) {
  3. coapRequest = Request.newPost();
  4. buildRequestSettings(request);
  5. coapRequest.getOptions().addUriPath("bs");
  6. coapRequest.getOptions().addUriQuery("ep=" + request.getClientEndpointIdentifier());
  7. parametersValid = true;
  8. }

代码示例来源:origin: org.eclipse.leshan/leshan-client

  1. @Override
  2. public void visit(final BootstrapRequest request) {
  3. coapRequest = Request.newPost();
  4. buildRequestSettings(request);
  5. coapRequest.getOptions().addUriPath("bs");
  6. coapRequest.getOptions().addUriQuery("ep=" + request.getClientEndpointIdentifier());
  7. parametersValid = true;
  8. }

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

  1. @Override
  2. public void visit(BootstrapRequest request) {
  3. coapRequest = Request.newPost();
  4. buildRequestSettings();
  5. coapRequest.getOptions().addUriPath("bs");
  6. coapRequest.getOptions().addUriQuery("ep=" + request.getEndpointName());
  7. }

代码示例来源:origin: org.eclipse.leshan/leshan-client

  1. @Override
  2. public void visit(final RegisterRequest request) {
  3. if (!areParametersValid(request.getClientParameters())) {
  4. return;
  5. }
  6. coapRequest = Request.newPost();
  7. buildRequestSettings(request);
  8. coapRequest.getOptions().addUriPath("rd");
  9. coapRequest.getOptions().addUriQuery("ep=" + request.getClientEndpointIdentifier());
  10. buildRequestContent(request);
  11. parametersValid = true;
  12. }

代码示例来源:origin: org.eclipse.leshan/leshan-server-cf

  1. @Override
  2. public void visit(ExecuteRequest request) {
  3. coapRequest = Request.newPost();
  4. setTarget(coapRequest, destination, request.getPath());
  5. coapRequest.setPayload(request.getParameters());
  6. if (request.getContentFormat() != null) {
  7. coapRequest.getOptions().setContentFormat(request.getContentFormat().getCode());
  8. }
  9. }

代码示例来源:origin: org.github.leshan/leshan-client

  1. @Override
  2. public void visit(final RegisterRequest request) {
  3. if (!areParametersValid(request.getClientParameters())) {
  4. return;
  5. }
  6. coapRequest = Request.newPost();
  7. buildRequestSettings(request);
  8. coapRequest.getOptions().addUriPath("rd");
  9. coapRequest.getOptions().addUriQuery("ep=" + request.getClientEndpointIdentifier());
  10. buildRequestContent(request);
  11. parametersValid = true;
  12. }

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

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

代码示例来源:origin: org.eclipse.leshan/leshan-server-cf

  1. @Override
  2. public void visit(CreateRequest request) {
  3. coapRequest = Request.newPost();
  4. coapRequest.getOptions().setContentFormat(request.getContentFormat().getCode());
  5. coapRequest.setPayload(LwM2mNodeEncoder.encode(request.getObjectInstance(), request.getContentFormat(),
  6. request.getPath()));
  7. setTarget(coapRequest, destination, request.getPath());
  8. }

代码示例来源:origin: org.eclipse.leshan/leshan-server-cf

  1. @Override
  2. public void visit(WriteRequest request) {
  3. coapRequest = request.isReplaceRequest() ? Request.newPut() : Request.newPost();
  4. coapRequest.getOptions().setContentFormat(request.getContentFormat().getCode());
  5. coapRequest
  6. .setPayload(LwM2mNodeEncoder.encode(request.getNode(), request.getContentFormat(), request.getPath()));
  7. setTarget(coapRequest, destination, request.getPath());
  8. }

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

  1. @Override
  2. public void visit(CreateRequest request) {
  3. coapRequest = Request.newPost();
  4. coapRequest.getOptions().setContentFormat(request.getContentFormat().getCode());
  5. // if no instance id, the client will assign it.
  6. int instanceId = request.getInstanceId() != null ? request.getInstanceId() : LwM2mObjectInstance.UNDEFINED;
  7. coapRequest.setPayload(encoder.encode(new LwM2mObjectInstance(instanceId, request.getResources()),
  8. request.getContentFormat(), request.getPath(), model));
  9. setTarget(coapRequest, request.getPath());
  10. }

相关文章