Transform OC_EH_OK into 2.02 for DELETE. 81/22281/3
authorTodd Malsbary <todd.malsbary@intel.com>
Wed, 30 Aug 2017 21:24:27 +0000 (14:24 -0700)
committerAshok Babu Channa <ashok.channa@samsung.com>
Fri, 22 Sep 2017 13:42:56 +0000 (13:42 +0000)
Currently OC_EH_OK is turned into 2.04 for POST or PUT.  This change
does the equivalent for DELETE.

Bug: https://jira.iotivity.org/browse/IOT-2660
Change-Id: I3b64d9c3a9471cdff25160ffab96928e0512fc33
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
resource/csdk/resource-directory/unittests/rdtests.cpp
resource/csdk/stack/src/ocserverrequest.c
resource/csdk/stack/src/ocstack.c

index 410bdb6..2e410cd 100644 (file)
@@ -98,7 +98,7 @@ static OCStackApplicationResult handleDeleteCB(__attribute__((unused))void *ctx,
 {
     OIC_LOG(DEBUG, TAG, "Successfully delete resources.");
 
-    EXPECT_EQ(OC_STACK_RESOURCE_CHANGED, clientResponse->result);
+    EXPECT_EQ(OC_STACK_RESOURCE_DELETED, clientResponse->result);
 
     return OC_STACK_DELETE_TRANSACTION;
 }
index e542052..953f8a1 100644 (file)
@@ -457,10 +457,14 @@ CAResponseResult_t ConvertEHResultToCAResult (OCEntityHandlerResult result, OCMe
         case OC_EH_OK:
         case OC_EH_CHANGED: // 2.04
         case OC_EH_CONTENT: // 2.05
-            if (method == OC_REST_POST || method == OC_REST_PUT || method == OC_REST_DELETE)
+            if (method == OC_REST_POST || method == OC_REST_PUT)
             {
                 caResult = CA_CHANGED;
             }
+            else if (method == OC_REST_DELETE)
+            {
+                caResult = CA_DELETED;
+            }
             else if (method == OC_REST_GET)
             {
                 caResult = CA_CONTENT;
index fc039e1..e795e8a 100644 (file)
@@ -889,6 +889,11 @@ CAResponseResult_t OCToCAStackResult(OCStackResult ocCode, OCMethod method)
                    // GET requests.
                    ret = CA_CONTENT;
                    break;
+               case OC_REST_DELETE:
+                   // This Response Code is like HTTP 200 "OK" but only used in response to
+                   // DELETE requests.
+                   ret = CA_DELETED;
+                   break;
                default:
                    // This should not happen but,
                    // give it a value just in case but output an error