samples/zoap_server: Add Content-Format options to GET responses
The Californium tests expects that all GET responses include the Content-Format information of the response. In our case, all responses are of type plain-text. Change-Id: I08844825f31ed8f4c54020a41b9172cef5da6d70 Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
This commit is contained in:
parent
0eaeaf2481
commit
e44dfffba2
1 changed files with 32 additions and 0 deletions
|
@ -39,6 +39,8 @@
|
|||
|
||||
static struct net_context *context;
|
||||
|
||||
static const uint8_t plain_text_format;
|
||||
|
||||
static int test_del(struct zoap_resource *resource,
|
||||
struct zoap_packet *request,
|
||||
const struct sockaddr *from)
|
||||
|
@ -276,6 +278,12 @@ static int piggyback_get(struct zoap_resource *resource,
|
|||
zoap_header_set_id(&response, id);
|
||||
zoap_header_set_token(&response, token, tkl);
|
||||
|
||||
r = zoap_add_option(&response, ZOAP_OPTION_CONTENT_FORMAT,
|
||||
&plain_text_format, sizeof(plain_text_format));
|
||||
if (r < 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
payload = zoap_packet_get_payload(&response, &len);
|
||||
if (!payload) {
|
||||
return -EINVAL;
|
||||
|
@ -371,6 +379,12 @@ static int query_get(struct zoap_resource *resource,
|
|||
zoap_header_set_id(&response, id);
|
||||
zoap_header_set_token(&response, token, tkl);
|
||||
|
||||
r = zoap_add_option(&response, ZOAP_OPTION_CONTENT_FORMAT,
|
||||
&plain_text_format, sizeof(plain_text_format));
|
||||
if (r < 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
payload = zoap_packet_get_payload(&response, &len);
|
||||
if (!payload) {
|
||||
return -EINVAL;
|
||||
|
@ -483,6 +497,12 @@ done:
|
|||
zoap_header_set_id(&response, id);
|
||||
zoap_header_set_token(&response, token, tkl);
|
||||
|
||||
r = zoap_add_option(&response, ZOAP_OPTION_CONTENT_FORMAT,
|
||||
&plain_text_format, sizeof(plain_text_format));
|
||||
if (r < 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
payload = zoap_packet_get_payload(&response, &len);
|
||||
if (!payload) {
|
||||
return -EINVAL;
|
||||
|
@ -566,6 +586,12 @@ static int large_get(struct zoap_resource *resource,
|
|||
zoap_header_set_id(&response, id);
|
||||
zoap_header_set_token(&response, token, tkl);
|
||||
|
||||
r = zoap_add_option(&response, ZOAP_OPTION_CONTENT_FORMAT,
|
||||
&plain_text_format, sizeof(plain_text_format));
|
||||
if (r < 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
r = zoap_add_block2_option(&response, &ctx);
|
||||
if (r < 0) {
|
||||
return -EINVAL;
|
||||
|
@ -658,6 +684,12 @@ static int large_update_put(struct zoap_resource *resource,
|
|||
zoap_header_set_id(&response, id);
|
||||
zoap_header_set_token(&response, token, tkl);
|
||||
|
||||
r = zoap_add_option(&response, ZOAP_OPTION_CONTENT_FORMAT,
|
||||
&plain_text_format, sizeof(plain_text_format));
|
||||
if (r < 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
r = zoap_add_block2_option(&response, &ctx);
|
||||
if (r < 0) {
|
||||
return -EINVAL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue