A stack which works with or without an Mbed os library. Provides IPv4 or IPv6 with a full 1500 byte buffer.

Dependents:   oldheating gps motorhome heating

Revision:
129:9c57197fb698
Parent:
126:62edacc9f14d
Child:
131:774f7f367031
--- a/tcp/http/http.c	Mon Mar 11 16:42:45 2019 +0000
+++ b/tcp/http/http.c	Wed Mar 13 07:51:38 2019 +0000
@@ -11,9 +11,7 @@
 bool HttpTrace = false;
 
 //Plumb into these from your html server
-int  (*HttpRequestFunction)(char *pPath, char *pLastModified);
-void (*HttpGetFunction    )(int todo, char *pQuery);
-bool (*HttpPostFunction   )(int todo, int contentLength, int contentStart, int size, char* pRequestStream, uint32_t positionInRequestStream);
+void (*HttpRequestFunction)(int size, char* pRequestStream, uint32_t positionInRequestStream, int* pToDo, bool* pPostComplete);
 void (*HttpReplyFunction  )(int todo);
 
 void HttpHandleRequest(int size, char* pRequestStream, uint32_t positionInRequestStream, int* pToDo, bool* pPostComplete)
@@ -25,33 +23,9 @@
     {
         LogF("HTTP  <<< %d (%u)\r\n", size, positionInRequestStream);
     }
-    //Handle request for the first packet of data received but leave todo the same after that.
-    int contentLength = 0;
-    int contentStart  = 0;
-    if (size && positionInRequestStream == 0)
-    {
-        //Read the headers
-        char* pMethod;
-        char* pPath;
-        char* pQuery;
-        char* pLastModified;
-        FaultPoint = FAULT_POINT_HttpReadRequest;
-        contentStart = HttpRequestRead(pRequestStream, size, &pMethod, &pPath, &pQuery, &pLastModified, &contentLength);
-        
-        //Ask the http server what to do
-        FaultPoint = FAULT_POINT_HttpRequestFunction;
-        *pToDo = HttpRequestFunction(pPath, pLastModified);
-        
-        //Handle the query
-        FaultPoint = FAULT_POINT_HttpGetFunction;
-        HttpGetFunction(*pToDo, pQuery);
-    }
     
-    //Do the upload of anything that needs it
-    FaultPoint = FAULT_POINT_HttpPostFunction;
-    if (!*pPostComplete) *pPostComplete = HttpPostFunction(*pToDo, contentLength, contentStart, size, pRequestStream, positionInRequestStream);
+    HttpRequestFunction(size, pRequestStream, positionInRequestStream, pToDo, pPostComplete);
     
-    //Tidy up
     FaultPoint = lastFaultPoint;
 }
 void HttpSendReply(int* pSize, char* pReplyStream, uint32_t positionInReplyStream, uint16_t mss, int todo)