WIZwiki-REST-io ver.2 Add POST Method

Dependencies:   MbedJSONValue_copy WIZnetInterface mbed

Fork of WIZwiki-REST_mc by Lawrence Lee

Revision:
4:0b5a199e91f3
Parent:
2:ca36ecca24c2
--- a/HTTPServer.cpp	Tue May 03 02:21:56 2016 +0000
+++ b/HTTPServer.cpp	Tue May 31 10:31:30 2016 +0000
@@ -104,22 +104,22 @@
         printf("Type = %s\r\n", request_type);
 #endif        
             
-                if(request_type)
+        if(request_type)
         {
-                      request = strtok(NULL, "  \r\n");                                                 // corrested  " " -> " /"     : /Name -> Name
+            request = strtok(NULL, "  \r\n");                                                 // corrested  " " -> " /"     : /Name -> Name
             if(request)
             {
 #ifdef DEBUG_HTTP                                    
                     printf("URI = %s\r\n", request);
 #endif                    
-                        }
-                        else
-                        {
-              strcpy(rest_result, "Invaild URI");
+             }
+             else
+             {
+                    strcpy(rest_result, "Invaild URI");
 #ifdef DEBUG_HTTP                              
-                            printf("%s\r\n",rest_result);
+                    printf("%s\r\n",rest_result);
 #endif                            
-              return HTTP_INVALID_URI;
+                    return HTTP_INVALID_URI;
             }
         }
     }
@@ -133,7 +133,17 @@
     //if(itor != NULL)
         //itor->handle(request, rest_result.c_str());
     if(itor->second != NULL)
-        itor->second->handle(request, rest_result);
+    {
+        char* request_data = 0;
+        if(!strcmp(request_type,"POST"))
+        {
+            request_data = strstr(request+strlen(request)+1, "\r\n\r\n");
+#ifdef DEBUG_HTTP
+            printf("POST:request_data=%s\r\n",request_data+4);
+#endif
+        }
+        itor->second->handle(request, request_data, rest_result);
+    }
     else
     {
         strcpy(rest_result, "Invalid request handler");