PelionIoT / mbed-coap

CoAP C library - Builder and Parser for CoAP messages
Apache License 2.0
29 stars 16 forks source link

Blockwise transfer ACK doesnt consider the uri query [v5.1.11] #142

Open noomio opened 1 year ago

noomio commented 1 year ago

Hi,

When doing a GET in the format:

coap://192.168.0.1/XXX?name=product-xxxx

The sn_coap_handle_blockwise_message doesnt build in the ACK response the uri query and the coap server after block #0 responds with internal server error, resource not found.

Adding the following code in line 2064 fixes it:

if (previous_blockwise_msg_ptr->coap_msg_ptr->options_list_ptr->uri_query_ptr) {

    src_coap_blockwise_ack_msg_ptr->options_list_ptr->uri_query_ptr = sn_coap_protocol_malloc_copy(handle, previous_blockwise_msg_ptr->coap_msg_ptr->options_list_ptr->uri_query_ptr, previous_blockwise_msg_ptr->coap_msg_ptr->options_list_ptr->uri_query_len);
    if (!src_coap_blockwise_ack_msg_ptr->options_list_ptr->uri_query_ptr) {
        sn_coap_parser_release_allocated_coap_msg_mem(handle, src_coap_blockwise_ack_msg_ptr);
        tr_error("sn_coap_handle_blockwise_message - failed to allocate for uri query ptr!");
        return NULL;
    }
    src_coap_blockwise_ack_msg_ptr->options_list_ptr->uri_query_len = previous_blockwise_msg_ptr->coap_msg_ptr->options_list_ptr->uri_query_len;
}
noomio commented 1 year ago

I created a pull request #143