Adaptation of the HttpServer by user yueee_yt. This version has improved handling of the HTTP headers (**NOTE**: There are limitations with this implementation and it is not fully functional. Use it only as a starting point.)

Dependents:   DMSupport DMSupport DMSupport DMSupport

Fork of DM_HttpServer by EmbeddedArtists AB

Revision:
10:c1c8276af541
Parent:
9:10b4d4075fbb
Child:
11:9dcff8cf906a
diff -r 10b4d4075fbb -r c1c8276af541 HTTPRequestHandler.cpp
--- a/HTTPRequestHandler.cpp	Mon Jan 26 10:10:46 2015 +0100
+++ b/HTTPRequestHandler.cpp	Wed Oct 23 06:58:32 2019 +0000
@@ -32,7 +32,7 @@
 //   m_pTCPSocketConnection(pTCPSocketConnection), m_reqHeaders(), m_respHeaders(),
 //   m_rootPath(rootPath), m_path(path), m_errc(200),
 //   m_watchdog(), m_timeout(0),**/ m_closed(false), m_headersSent(false) //OK
-HTTPRequestHandler::HTTPRequestHandler(const char* rootPath, const char* path, TCPSocketConnection* pTCPSocketConnection) :
+HTTPRequestHandler::HTTPRequestHandler(const char* rootPath, const char* path, TCPSocket* pTCPSocketConnection) :
     m_pTCPSocketConnection(pTCPSocketConnection), m_reqHeaders(), m_respHeaders(),
     m_rootPath(rootPath), m_path(path), m_errc(200), m_closed(false), m_headersSent(false)
 {
@@ -96,7 +96,7 @@
 
 int HTTPRequestHandler::readData(char* buf, int len)
 {
-    return m_pTCPSocketConnection->receive(buf, len);
+    return m_pTCPSocketConnection->recv(buf, len);
 }
 
 string& HTTPRequestHandler::rootPath() //const
@@ -194,7 +194,7 @@
     int ret;
     int len = 0;
     for(int i = 0; i < maxLen - 1; i++) {
-        ret = m_pTCPSocketConnection->receive(str, 1);
+        ret = m_pTCPSocketConnection->recv(str, 1);
         if(!ret) {
             break;
         }
@@ -224,7 +224,7 @@
     while (i < maxLen && !found) {
         if (cache->num <= cache->pos) {
             // get something to process
-            int ret = m_pTCPSocketConnection->receive(cache->buff, cache->size);
+            int ret = m_pTCPSocketConnection->recv(cache->buff, cache->size);
             if(ret == -1) {
                 // error
                 break;