New EthernetInterface Version HTTPServer Library only SimpleHandler Test

Dependents:   HttpServerSample giken9_HTMLServer_Sample giken9_HTMLServer_Temp_Sample RPCHTTPServer

Files at this revision

API Documentation at this revision

Comitter:
yueee_yt
Date:
Sat Feb 22 05:51:59 2014 +0000
Parent:
4:1b6b021ee21d
Commit message:
BugFix(RPCHandler)

Changed in this revision

Handler/FSHandler.cpp Show annotated file Show diff for this revision Revisions of this file
Handler/RPCHandler.cpp Show annotated file Show diff for this revision Revisions of this file
Handler/SimpleHandler.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Handler/FSHandler.cpp	Fri Feb 21 07:10:30 2014 +0000
+++ b/Handler/FSHandler.cpp	Sat Feb 22 05:51:59 2014 +0000
@@ -17,15 +17,10 @@
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 */
-#ifdef _DEBUG_ALL
-#define _DEBUG_FS_HANDLER
-#endif
+//#define _DEBUG_FS_HANDLER
 
 #include "FSHandler.h"
 
-//#define __DEBUG
-//#include "dbg/dbg.h"
-
 #define CHUNK_SIZE 128
 
 #define DEFAULT_PAGE "/index.htm"
@@ -36,9 +31,20 @@
 
 FSHandler::~FSHandler()
 {
-    if(m_fp)
+#ifdef _DEBUG_FS_HANDLER
+    printf("\r\n+++FSHandler destroy\r\n");
+#endif
+    if(m_fp){
+#ifdef _DEBUG_FS_HANDLER
+    printf("\r\n+++FSHandler fclose start\r\n");
+#endif
         fclose(m_fp);
 #ifdef _DEBUG_FS_HANDLER
+    printf("\r\n+++FSHandler fclose end\r\n");
+#endif
+       
+        }
+#ifdef _DEBUG_FS_HANDLER
     printf("\r\nHandler destroyed\r\n");
 #endif
 }
@@ -130,16 +136,18 @@
 #ifdef _DEBUG_FS_HANDLER
                 printf("FSHandler: Socket error %d\n", writtenLen);
 #endif
-/**  Not Work
-                if(writtenLen == TCPSOCKET_MEM) {
-                    fseek(m_fp, -len, SEEK_CUR);
-                    return; //Wait for the queued TCP segments to be transmitted
-                } else {
-                    //This is a critical error
-                    close();
-                    return;
-                }
-**/
+                /**  Not Work
+                                if(writtenLen == TCPSOCKET_MEM) {
+                                    fseek(m_fp, -len, SEEK_CUR);
+                                    return; //Wait for the queued TCP segments to be transmitted
+                                } else {
+                                    //This is a critical error
+                                    **/
+                                    close();
+                                    return;
+                                    /**
+                                }
+                **/
             } else if(writtenLen < len) { //Short write, socket's buffer is full
                 fseek(m_fp, writtenLen - len, SEEK_CUR);
                 return;
@@ -153,6 +161,21 @@
 
 void FSHandler::onClose() //Connection is closing
 {
-    if(m_fp)
-        fclose(m_fp);
+    /**
+#ifdef _DEBUG_FS_HANDLER
+        printf("FSHandler: onClose start \r\n");
+#endif
+    if(m_fp){
+#ifdef _DEBUG_FS_HANDLER
+        printf("FSHandler: fclose start \r\n");
+#endif
+    fclose(m_fp);
+#ifdef _DEBUG_FS_HANDLER
+    printf("FSHandler: fclose end \r\n");
+#endif
 }
+#ifdef _DEBUG_FS_HANDLER
+        printf("FSHandler: onClose end \r\n");
+#endif
+**/
+}
--- a/Handler/RPCHandler.cpp	Fri Feb 21 07:10:30 2014 +0000
+++ b/Handler/RPCHandler.cpp	Sat Feb 22 05:51:59 2014 +0000
@@ -17,9 +17,8 @@
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 */
-#ifdef _DEBUG_ALL
-#define _DEBUG_RPC_HANDLER
-#endif
+
+//#define _DEBUG_RPC_HANDLER
 
 #include "RPCHandler.h"
 #include "mbed_rpc.h"
@@ -32,43 +31,42 @@
 RPCHandler::~RPCHandler()
 {
 #ifdef _DEBUG_RPC_HANDLER
-    printf("\r\nHandler destroyed\r\n");
+    printf("++++(RPC Handler)Handler destroyed\r\n");
 #endif
 }
 
 void RPCHandler::doGet()
 {
 #ifdef _DEBUG_RPC_HANDLER
-    printf("\r\nIn RPCHandler::doGet()\r\n");
+    printf("++++(RPC Handler)doGet\r\n");
 #endif
     char resp[RPC_DATA_LEN] = {0};
     char req[RPC_DATA_LEN] = {0};
 
 #ifdef _DEBUG_RPC_HANDLER
-    printf("\r\nPath : %s\r\n", path().c_str());
-    printf("\r\nRoot Path : %s\r\n", rootPath().c_str());
+    printf("++++(RPC Handler)Path : %s\r\n", path().c_str());
+    printf("++++(RPC Handler)Root Path : %s\r\n", rootPath().c_str());
 #endif
     //Remove path
     strncpy(req, path().c_str(), RPC_DATA_LEN-1);
 #ifdef _DEBUG_RPC_HANDLER
-    printf("\r\nRPC req : %s\r\n", req);
+    printf("++++(RPC Handler)RPC req(before) : %s\r\n", req);
 #endif
-    //Remove %20, +, from req
+    //Remove "%20", "+", "," from req
     cleanReq(req);
 #ifdef _DEBUG_RPC_HANDLER
-    printf("\r\nRPC req : %s\r\n", req);
+    printf("++++(RPC Handler)RPC req(after) : %s\r\n", req);
 #endif
     //Do RPC Call
     RPC::call(req, resp); //FIXME: Use bool result
 #ifdef _DEBUG_RPC_HANDLER
-    printf("RPC Response %s \r\n",resp);
+    printf("++++(RPC Handler)Response %s \r\n",resp);
 #endif
     //Response
     setContentLen( strlen(resp) );
 
     //Make sure that the browser won't cache this request
     respHeaders()["Cache-control"]="no-cache;no-store";
-// respHeaders()["Cache-control"]="no-store";
     respHeaders()["Pragma"]="no-cache";
     respHeaders()["Expires"]="0";
 
@@ -76,7 +74,7 @@
     respHeaders()["Connection"] = "close";
     writeData(resp, strlen(resp));
 #ifdef _DEBUG_RPC_HANDLER
-    printf("\r\nExit RPCHandler::doGet()\r\n");
+    printf("++++(RPC Handler)Exit RPCHandler::doGet()\r\n");
 #endif
 }
 
@@ -99,9 +97,9 @@
 void RPCHandler::onWriteable() //Data has been written & buf is free
 {
 #ifdef _DEBUG_RPC_HANDLER
-    printf("\r\nRPCHandler::onWriteable() event\r\n");
+    printf("++++(RPC Handler)onWriteable event\r\n");
 #endif
-    close(); //Data written, we can close the connection
+   // close(); //Data written, we can close the connection
 }
 
 void RPCHandler::onClose() //Connection is closing
@@ -133,3 +131,4 @@
     }
 }
 
+
--- a/Handler/SimpleHandler.cpp	Fri Feb 21 07:10:30 2014 +0000
+++ b/Handler/SimpleHandler.cpp	Sat Feb 22 05:51:59 2014 +0000
@@ -19,9 +19,7 @@
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 */
-#ifdef _DEBUG_ALL
 #define _DEBUG_SIMPLE_HANDLER
-#endif
 
 #include "SimpleHandler.h"
 
@@ -74,7 +72,7 @@
 #ifdef _DEBUG_SIMPLE_HANDLER
     printf("\r\n++++SimpleHandler::onWriteable() event\r\n");
 #endif
-    close(); //Data written, we can close the connection
+//    close(); //Data written, we can close the connection
 }
 
 void SimpleHandler::onClose() //Connection is closing