Fixing query delimiters in uri reassembly.
authorMandeep Shetty <mandeep.shetty@intel.com>
Fri, 27 Feb 2015 23:30:19 +0000 (15:30 -0800)
committerSashi Penta <sashi.kumar.penta@intel.com>
Tue, 10 Mar 2015 08:32:07 +0000 (08:32 +0000)
The first delimiter after the uri and before the query is '?'
All eventual delimiters between query params are '&'.
This is missed out on the patch :
https://gerrit.iotivity.org/gerrit/#/c/193.

Change-Id: Iec533d10075e1692a84b36683b0b42b2b702a01e
Signed-off-by: Mandeep Shetty <mandeep.shetty@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/422
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Joseph Morrow <joseph.l.morrow@intel.com>
Reviewed-by: jihwan seo <jihwan.seo@samsung.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
Reviewed-by: Sashi Penta <sashi.kumar.penta@intel.com>
resource/csdk/connectivity/src/caprotocolmessage.c
resource/csdk/connectivity/src/caprotocolmessage_singlethread.c

index b852ae973c46bf41c7962fa1fba0ef24aaa3ec5a..23304a10d5de3fb71df3a2904bbb511bbffd8aa9 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <string.h>
 #include <time.h>
 
@@ -470,6 +471,7 @@ void CAGetRequestPDUInfo(const coap_pdu_t *pdu, uint32_t *outCode, CAInfo_t *out
     uint32_t count = 0, idx = 0;
     uint32_t optionLength = 0;
     uint32_t isfirstsetflag = 0;
+    bool isQueryBeingProcessed = false;
 
     coap_option_iterator_init((coap_pdu_t *) pdu, &opt_iter, COAP_OPT_ALL);
 
@@ -526,7 +528,17 @@ void CAGetRequestPDUInfo(const coap_pdu_t *pdu, uint32_t *outCode, CAInfo_t *out
                     }
                     else if (COAP_OPTION_URI_QUERY == opt_iter.type)
                     {
-                        memcpy(optionResult + optionLength, "?", 1);
+                        // Delimiter between uri and query is '?'
+                        if (false == isQueryBeingProcessed)
+                        {
+                            memcpy(optionResult + optionLength, "?", 1);
+                            isQueryBeingProcessed = true;
+                        }
+                        else
+                        {
+                            // Delimeter for query params is '&'
+                            memcpy(optionResult + optionLength, "&", 1);
+                        }
                         optionLength++;
                     }
                     memcpy(optionResult + optionLength, buf, strlen((const char *) buf));
index c011eaec63faa50c83ae7fdc839d890748fa1e56..9283efc560d980f24d95a177903953f981285ecb 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <string.h>
 
 
@@ -468,6 +469,7 @@ void CAGetRequestPDUInfo(const coap_pdu_t *pdu, uint32_t *outCode, CAInfo_t *out
     uint32_t count = 0, idx = 0;
     uint32_t optionLength = 0;
     uint32_t isfirstsetflag = 0;
+    bool isQueryBeingProcessed = false;
 
     coap_option_iterator_init((coap_pdu_t *) pdu, &opt_iter, COAP_OPT_ALL);
 
@@ -525,7 +527,17 @@ void CAGetRequestPDUInfo(const coap_pdu_t *pdu, uint32_t *outCode, CAInfo_t *out
                     }
                     else if (COAP_OPTION_URI_QUERY == opt_iter.type)
                     {
-                        memcpy(optionResult + optionLength, "?", 1);
+                        // Delimiter between uri and query is '?'
+                        if (false == isQueryBeingProcessed)
+                        {
+                            memcpy(optionResult + optionLength, "?", 1);
+                            isQueryBeingProcessed = true;
+                        }
+                        else
+                        {
+                            // Delimeter for query params is '&'
+                            memcpy(optionResult + optionLength, "&", 1);
+                        }
                         optionLength++;
                     }
                     memcpy(optionResult + optionLength, buf, strlen((const char *) buf));