HttpServer Library for "mbed-os" which added a snapshot handler.

Dependents:   GR-PEACH-webcam GR-Boards_WebCamera GR-Boards_WebCamera GR-Boards_WebCamera

Fork of HttpServer_snapshot by Renesas

Revision:
4:1b6b021ee21d
Parent:
0:fdf9c2c5200f
Child:
6:d9e6379eefac
diff -r 87c6439f4136 -r 1b6b021ee21d HTTPRequestHandler.cpp
--- a/HTTPRequestHandler.cpp	Thu Feb 20 13:11:34 2014 +0000
+++ b/HTTPRequestHandler.cpp	Fri Feb 21 07:10:30 2014 +0000
@@ -17,15 +17,14 @@
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 */
+#ifdef _DEBUG_ALL
+#define _DEBUG_REQUEST_HANDLER
+#endif
 
-//#include "core/netservice.h"
 #include "HTTPRequestHandler.h"
 
 #include <string.h>
 
-//#define __DEBUG
-//#include "dbg/dbg.h"
-
 #define HTTP_REQUEST_TIMEOUT 5000
 
 //HTTPRequestHandler::HTTPRequestHandler(const char* rootPath, const char* path, TCPSocket* pTCPSocket) : NetService(),
@@ -36,18 +35,24 @@
     m_pTCPSocketConnection(pTCPSocketConnection), m_reqHeaders(), m_respHeaders(),
     m_rootPath(rootPath), m_path(path), m_errc(200), m_closed(false), m_headersSent(false)
 {
+#ifdef _DEBUG_REQUEST_HANDLER
     printf("+++(HTTPRequestHandler) init \r\n");
+#endif
     //Read & parse headers
     readHeaders();
 //*  m_pTCPSocket->setOnEvent(this, &HTTPRequestHandler::onTCPSocketEvent);
 //*  setTimeout(HTTP_REQUEST_TIMEOUT);
+#ifdef _DEBUG_REQUEST_HANDLER
     printf("+++(HTTPRequestHandler) init end \r\n");
+#endif
 }
 
 HTTPRequestHandler::~HTTPRequestHandler()
 {
     close();
+#ifdef _DEBUG_REQUEST_HANDLER
     printf("+++(HTTPRequestHandler) Destroy end\r\n");
+#endif
 }
 
 void HTTPRequestHandler::onTimeout() //Connection has timed out
@@ -146,7 +151,9 @@
     while( readLine(line, 128) > 0) { //if == 0, it is an empty line = end of headers
         int n = sscanf(line, "%[^:]: %[^\n]", key, value);
         if ( n == 2 ) {
+#ifdef _DEBUG_REQUEST_HANDLER
             printf("\r\n+++(HTTPRequestHandler)Read header : %s : %s\r\n", key, value);
+#endif
             m_reqHeaders[key] = value;
         }
         //TODO: Impl n==1 case (part 2 of previous header)
@@ -165,7 +172,9 @@
     while( !m_respHeaders.empty() ) {
         it = m_respHeaders.begin();
         sprintf(line, "%s: %s\r\n", (*it).first.c_str(), (*it).second.c_str() );
+#ifdef _DEBUG_REQUEST_HANDLER
         printf("\r\n+++(HTTPRequestHandler)%s", line);
+#endif
         m_pTCPSocketConnection->send(line, strlen(line));
         m_respHeaders.erase(it);
     }