本文整理了Java中org.eclipse.californium.core.coap.Request.setPayload
方法的一些代码示例,展示了Request.setPayload
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.setPayload
方法的具体详情如下:
包路径:org.eclipse.californium.core.coap.Request
类名称:Request
方法名:setPayload
[英]Required in Request to keep class for fluent API.
[中]请求中要求保留fluent API的类。
代码示例来源:origin: org.eclipse.leshan/leshan-client
private void buildRequestContent(final LwM2mContentRequest request) {
for (final Entry<String, String> entry : request.getClientParameters().entrySet()) {
coapRequest.getOptions().addUriQuery(entry.getKey() + "=" + entry.getValue());
}
final String payload = LinkFormatUtils.payloadize(clientObjectModel);
coapRequest.setPayload(payload);
}
代码示例来源: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 CC03(String serverURI) {
super(CC03.class.getSimpleName());
// create the request
Request request = Request.newPut();
// add payload
request.setPayload("TD_COAP_CORE_03");
request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
// set the parameters and execute the request
executeRequest(request, serverURI, RESOURCE_URI);
}
代码示例来源:origin: eclipse/californium
public CC07(String serverURI) {
super(CC07.class.getSimpleName());
// create the request
Request request = new Request(Code.PUT);
request.setConfirmable(false);
// add payload
request.setPayload("TD_COAP_CORE_07");
request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
// set the parameters and execute the request
executeRequest(request, serverURI, RESOURCE_URI);
}
代码示例来源:origin: eclipse/californium
/**
* Sends a PUT request with payload and required Content-Format and blocks
* until the response is available.
*
* @param payload the payload
* @param format the Content-Format
* @return the CoAP response
*/
public CoapResponse put(byte[] payload, int format) {
return synchronous(format(newPut().setURI(uri).setPayload(payload), format));
}
代码示例来源:origin: eclipse/californium
/**
* Sends a POST request with the specified payload and the specified content
* format and invokes the specified handler when a response arrives.
*
* @param handler the Response handler
* @param payload the payload
* @param format the Content-Format
*/
public void post(CoapHandler handler, String payload, int format) {
asynchronous(format(newPost().setURI(uri).setPayload(payload), format), handler);
}
代码示例来源:origin: eclipse/californium
/**
* Sends a PUT request with payload and required Content-Format and blocks
* until the response is available.
*
* @param payload the payload
* @param format the Content-Format
* @return the CoAP response
*/
public CoapResponse put(String payload, int format) {
return synchronous(format(newPut().setURI(uri).setPayload(payload), format));
}
代码示例来源:origin: eclipse/californium
/**
* Sends a PUT request with the specified payload and the specified content
* format and invokes the specified handler when a response arrives.
*
* @param handler the Response handler
* @param payload the payload
* @param format the Content-Format
*/
public void put(CoapHandler handler, byte[] payload, int format) {
asynchronous(format(newPut().setURI(uri).setPayload(payload), format), handler);
}
代码示例来源:origin: eclipse/californium
/**
* Sends a POST request with the specified payload and the specified content
* format and invokes the specified handler when a response arrives.
*
* @param handler the Response handler
* @param payload the payload
* @param format the Content-Format
*/
public void post(CoapHandler handler, byte[] payload, int format) {
asynchronous(format(newPost().setURI(uri).setPayload(payload), format), handler);
}
代码示例来源: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: org.eclipse.californium/californium-core
/**
* Sends a PUT request with the If-None-Match option set and blocks until
* the response is available.
*
* @param payload the payload string
* @param format the Content-Format
* @return the CoAP response
*/
public CoapResponse putIfNoneMatch(String payload, int format) {
return synchronous(ifNoneMatch(format(Request.newPut().setURI(uri).setPayload(payload), format)));
}
代码示例来源:origin: eclipse/californium
/**
* Sends a PUT request with with the specified ETags in the If-Match option
* and blocks until the response is available.
*
* @param payload the payload string
* @param format the Content-Format
* @param etags the ETags for the If-Match option
* @return the CoAP response
*/
public CoapResponse putIfMatch(String payload, int format, byte[] ... etags) {
return synchronous(ifMatch(format(newPut().setURI(uri).setPayload(payload), format), etags));
}
代码示例来源:origin: eclipse/californium
/**
* Sends a PUT request with the If-None-Match option set and blocks until
* the response is available.
*
* @param payload the payload
* @param format the Content-Format
* @return the CoAP response
*/
public CoapResponse putIfNoneMatch(byte[] payload, int format) {
return synchronous(ifNoneMatch(format(newPut().setURI(uri).setPayload(payload), format)));
}
代码示例来源:origin: eclipse/californium
/**
*
* @param handler the Response handler
* @param payload the payload
* @param format the Content-Format
* @param etags the ETags for the If-Match option
*/
public void putIfMatch(CoapHandler handler, byte[] payload, int format, byte[] ... etags) {
asynchronous(ifMatch(format(newPut().setURI(uri).setPayload(payload), format), etags), handler);
}
代码示例来源:origin: eclipse/californium
/**
*
* @param handler the Response handler
* @param payload the payload
* @param format the Content-Format
*/
public void putIfNoneMatch(CoapHandler handler, byte[] payload, int format) {
asynchronous(ifNoneMatch(format(newPut().setURI(uri).setPayload(payload), format)), handler);
}
代码示例来源:origin: org.eclipse.californium/californium-core
/**
*
* @param handler the Response handler
* @param payload the payload
* @param format the Content-Format
* @param etags the ETags for the If-Match option
*/
public void putIfMatch(CoapHandler handler, byte[] payload, int format, byte[] ... etags) {
asynchronous(ifMatch(format(Request.newPut().setURI(uri).setPayload(payload), format), etags), handler);
}
代码示例来源:origin: eclipse/leshan
@Override
public void visit(WriteRequest request) {
coapRequest = request.isReplaceRequest() ? Request.newPut() : Request.newPost();
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/leshan
@Override
public void visit(CreateRequest request) {
coapRequest = Request.newPost();
coapRequest.getOptions().setContentFormat(request.getContentFormat().getCode());
// if no instance id, the client will assign it.
int instanceId = request.getInstanceId() != null ? request.getInstanceId() : LwM2mObjectInstance.UNDEFINED;
coapRequest.setPayload(encoder.encode(new LwM2mObjectInstance(instanceId, request.getResources()),
request.getContentFormat(), request.getPath(), model));
setTarget(coapRequest, request.getPath());
}
内容来源于网络,如有侵权,请联系作者删除!