Commit 27c0247b authored by Kishen Maloor's avatar Kishen Maloor

Store response media type in oc_response_buffer_t

Signed-off-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
parent 133f8b07
...@@ -922,7 +922,7 @@ oc_handle_collection_request(oc_method_t method, oc_request_t *request, ...@@ -922,7 +922,7 @@ oc_handle_collection_request(oc_method_t method, oc_request_t *request,
break; break;
} }
} }
request->response->content_format = APPLICATION_VND_OCF_CBOR; request->response->response_buffer->content_format = APPLICATION_VND_OCF_CBOR;
request->response->response_buffer->response_length = (uint16_t)size; request->response->response_buffer->response_length = (uint16_t)size;
request->response->response_buffer->code = code; request->response->response_buffer->code = code;
......
...@@ -447,7 +447,7 @@ oc_core_1_1_discovery_handler(oc_request_t *request, ...@@ -447,7 +447,7 @@ oc_core_1_1_discovery_handler(oc_request_t *request,
} }
int response_length = oc_rep_get_encoded_payload_size(); int response_length = oc_rep_get_encoded_payload_size();
request->response->content_format = APPLICATION_CBOR; request->response->response_buffer->content_format = APPLICATION_CBOR;
if (matches && response_length) { if (matches && response_length) {
request->response->response_buffer->response_length = request->response->response_buffer->response_length =
(uint16_t)response_length; (uint16_t)response_length;
...@@ -500,7 +500,7 @@ oc_core_discovery_handler(oc_request_t *request, oc_interface_mask_t iface_mask, ...@@ -500,7 +500,7 @@ oc_core_discovery_handler(oc_request_t *request, oc_interface_mask_t iface_mask,
break; break;
} }
int response_length = oc_rep_get_encoded_payload_size(); int response_length = oc_rep_get_encoded_payload_size();
request->response->content_format = APPLICATION_VND_OCF_CBOR; request->response->response_buffer->content_format = APPLICATION_VND_OCF_CBOR;
if (matches && response_length > 0) { if (matches && response_length > 0) {
request->response->response_buffer->response_length = request->response->response_buffer->response_length =
(uint16_t)response_length; (uint16_t)response_length;
......
...@@ -78,7 +78,7 @@ oc_core_introspection_data_handler(oc_request_t *request, ...@@ -78,7 +78,7 @@ oc_core_introspection_data_handler(oc_request_t *request,
IDD_size = oc_storage_read( IDD_size = oc_storage_read(
idd_tag, request->response->response_buffer->buffer, OC_MAX_APP_DATA_SIZE); idd_tag, request->response->response_buffer->buffer, OC_MAX_APP_DATA_SIZE);
#endif /* OC_IDD_API */ #endif /* OC_IDD_API */
request->response->content_format = APPLICATION_VND_OCF_CBOR; request->response->response_buffer->content_format = APPLICATION_VND_OCF_CBOR;
if (IDD_size >= 0 && IDD_size < OC_MAX_APP_DATA_SIZE) { if (IDD_size >= 0 && IDD_size < OC_MAX_APP_DATA_SIZE) {
request->response->response_buffer->response_length = (uint16_t)IDD_size; request->response->response_buffer->response_length = (uint16_t)IDD_size;
request->response->response_buffer->code = oc_status_code(OC_STATUS_OK); request->response->response_buffer->code = oc_status_code(OC_STATUS_OK);
......
...@@ -687,10 +687,10 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response, uint8_t *buffer, ...@@ -687,10 +687,10 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response, uint8_t *buffer,
*/ */
response_buffer.code = 0; response_buffer.code = 0;
response_buffer.response_length = 0; response_buffer.response_length = 0;
response_buffer.content_format = 0;
response_obj.separate_response = NULL; response_obj.separate_response = NULL;
response_obj.response_buffer = &response_buffer; response_obj.response_buffer = &response_buffer;
response_obj.content_format = 0;
request_obj.response = &response_obj; request_obj.response = &response_obj;
request_obj.request_payload = NULL; request_obj.request_payload = NULL;
...@@ -1125,8 +1125,9 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response, uint8_t *buffer, ...@@ -1125,8 +1125,9 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response, uint8_t *buffer,
coap_set_payload(response, response_buffer.buffer, coap_set_payload(response, response_buffer.buffer,
response_buffer.response_length); response_buffer.response_length);
#endif /* !OC_BLOCK_WISE */ #endif /* !OC_BLOCK_WISE */
if (response_obj.content_format > 0) { if (response_buffer.content_format > 0) {
coap_set_header_content_format(response, response_obj.content_format); coap_set_header_content_format(response,
response_buffer.content_format);
} }
} }
......
...@@ -75,11 +75,12 @@ oc_send_response(oc_request_t *request, oc_status_t response_code) ...@@ -75,11 +75,12 @@ oc_send_response(oc_request_t *request, oc_status_t response_code)
{ {
#ifdef OC_SPEC_VER_OIC #ifdef OC_SPEC_VER_OIC
if (request->origin && request->origin->version == OIC_VER_1_1_0) { if (request->origin && request->origin->version == OIC_VER_1_1_0) {
request->response->content_format = APPLICATION_CBOR; request->response->response_buffer->content_format = APPLICATION_CBOR;
} else } else
#endif /* OC_SPEC_VER_OIC */ #endif /* OC_SPEC_VER_OIC */
{ {
request->response->content_format = APPLICATION_VND_OCF_CBOR; request->response->response_buffer->content_format =
APPLICATION_VND_OCF_CBOR;
} }
request->response->response_buffer->response_length = request->response->response_buffer->response_length =
(uint16_t)response_length(); (uint16_t)response_length();
...@@ -196,7 +197,7 @@ oc_send_response_raw(oc_request_t *request, const uint8_t *payload, size_t size, ...@@ -196,7 +197,7 @@ oc_send_response_raw(oc_request_t *request, const uint8_t *payload, size_t size,
oc_content_format_t content_format, oc_content_format_t content_format,
oc_status_t response_code) oc_status_t response_code)
{ {
request->response->content_format = content_format; request->response->response_buffer->content_format = content_format;
memcpy(request->response->response_buffer->buffer, payload, size); memcpy(request->response->response_buffer->buffer, payload, size);
request->response->response_buffer->response_length = (uint16_t)size; request->response->response_buffer->response_length = (uint16_t)size;
request->response->response_buffer->code = oc_status_code(response_code); request->response->response_buffer->code = oc_status_code(response_code);
...@@ -423,6 +424,7 @@ oc_send_separate_response(oc_separate_response_t *handle, ...@@ -423,6 +424,7 @@ oc_send_separate_response(oc_separate_response_t *handle,
response_buffer.buffer = handle->buffer; response_buffer.buffer = handle->buffer;
response_buffer.response_length = (uint16_t)response_length(); response_buffer.response_length = (uint16_t)response_length();
response_buffer.code = oc_status_code(response_code); response_buffer.code = oc_status_code(response_code);
response_buffer.content_format = APPLICATION_VND_OCF_CBOR;
coap_separate_t *cur = oc_list_head(handle->requests), *next = NULL; coap_separate_t *cur = oc_list_head(handle->requests), *next = NULL;
coap_packet_t response[1]; coap_packet_t response[1];
...@@ -435,14 +437,8 @@ oc_send_separate_response(oc_separate_response_t *handle, ...@@ -435,14 +437,8 @@ oc_send_separate_response(oc_separate_response_t *handle,
if (t) { if (t) {
coap_separate_resume(response, cur, coap_separate_resume(response, cur,
(uint8_t)oc_status_code(response_code), t->mid); (uint8_t)oc_status_code(response_code), t->mid);
#ifdef OC_SPEC_VER_OIC coap_set_header_content_format(response,
if (cur->endpoint.version == OIC_VER_1_1_0) { response_buffer.content_format);
coap_set_header_content_format(response, APPLICATION_CBOR);
} else
#endif /* OC_SPEC_VER_OIC */
{
coap_set_header_content_format(response, APPLICATION_VND_OCF_CBOR);
}
#ifdef OC_BLOCK_WISE #ifdef OC_BLOCK_WISE
oc_blockwise_state_t *response_state = NULL; oc_blockwise_state_t *response_state = NULL;
......
...@@ -100,7 +100,6 @@ typedef struct oc_response_t ...@@ -100,7 +100,6 @@ typedef struct oc_response_t
{ {
oc_separate_response_t *separate_response; oc_separate_response_t *separate_response;
oc_response_buffer_t *response_buffer; oc_response_buffer_t *response_buffer;
oc_content_format_t content_format;
} oc_response_t; } oc_response_t;
typedef enum { typedef enum {
......
...@@ -823,9 +823,9 @@ coap_notify_observers(oc_resource_t *resource, ...@@ -823,9 +823,9 @@ coap_notify_observers(oc_resource_t *resource,
} else { } else {
coap_set_header_observe(notification, 1); coap_set_header_observe(notification, 1);
} }
if (response.content_format > 0) { if (response_buf->content_format > 0) {
coap_set_header_content_format(notification, coap_set_header_content_format(notification,
response.content_format); response_buf->content_format);
} }
coap_set_token(notification, obs->token, obs->token_len); coap_set_token(notification, obs->token, obs->token_len);
transaction = coap_new_transaction(coap_get_mid(), &obs->endpoint); transaction = coap_new_transaction(coap_get_mid(), &obs->endpoint);
......
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
#include "separate.h" #include "separate.h"
#include "util/oc_list.h" #include "util/oc_list.h"
#include "oc_ri.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C" {
{
#endif #endif
struct oc_separate_response_s struct oc_separate_response_s
...@@ -42,6 +42,7 @@ struct oc_response_buffer_s ...@@ -42,6 +42,7 @@ struct oc_response_buffer_s
uint16_t buffer_size; uint16_t buffer_size;
uint16_t response_length; uint16_t response_length;
int code; int code;
oc_content_format_t content_format;
}; };
#ifdef __cplusplus #ifdef __cplusplus
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment