Single instance HTTP Server using WiFly Interface.

Dependents:   WiFlyHTTPServerSample MultiThreadingHTTPServer

This is my implementation for a HTTP Server using the WiFly Interface. Please note that this is still under development.

It may still contain several bugs. I have tested it using a 1768 on an application board plus RN-XV board.

Currently there is only a FileSystem implemented. Also it is limited to GET request.

I try to extend it further so it will be more useful.

Btw, it does NOT work with RTOS, which seems not to be the Problem of my library.

Do not Forget to Import the WiFly Interface into your Project when using this library.

Change History:

REV5: - added support for basic RPC GET request functionality.

REV4: - added argument parsing from the request uri. - documentation extended and updated.

Files at this revision

API Documentation at this revision

Comitter:
leihen
Date:
Sat Jun 01 16:49:17 2013 +0000
Parent:
5:dc88012caef1
Child:
7:cb7fec1265b5
Commit message:
Added DEBUG preprocessor constant to each file.
; Added non-blocking polling function.

Changed in this revision

HTTPConnection.cpp Show annotated file Show diff for this revision Revisions of this file
HTTPRequestHandler.cpp Show annotated file Show diff for this revision Revisions of this file
HTTPServer.cpp Show annotated file Show diff for this revision Revisions of this file
HTTPServer.h Show annotated file Show diff for this revision Revisions of this file
--- a/HTTPConnection.cpp	Sat Jun 01 06:24:43 2013 +0000
+++ b/HTTPConnection.cpp	Sat Jun 01 16:49:17 2013 +0000
@@ -3,12 +3,14 @@
 #include "mbed.h"
 #include "HTTPConnection.h"
 
+#define _DEBUG 0
+
 #include <vector>
 using std::vector;
 
 using std::string;
 
-#if (1 && !defined(TARGET_LPC11U24))
+#if (_DEBUG && !defined(TARGET_LPC11U24))
 #define INFO(x, ...) std::printf("[HttpConnection : INFO]"x"\r\n", ##__VA_ARGS__);
 #define WARN(x, ...) std::printf("[HttpConnection : WARN]"x"\r\n", ##__VA_ARGS__);
 #define ERR(x, ...) std::printf("[HttpConnection : ERR]"x"\r\n", ##__VA_ARGS__);
--- a/HTTPRequestHandler.cpp	Sat Jun 01 06:24:43 2013 +0000
+++ b/HTTPRequestHandler.cpp	Sat Jun 01 16:49:17 2013 +0000
@@ -2,7 +2,9 @@
 #include "mbed.h"
 #include "HTTPRequestHandler.h"
 
-#if (1 && !defined(TARGET_LPC11U24))
+#define _DEBUG 0
+
+#if (_DEBUG && !defined(TARGET_LPC11U24))
 #define INFO(x, ...) std::printf("[HTTPRequestHandler : DBG]"x"\r\n", ##__VA_ARGS__);
 #define WARN(x, ...) std::printf("[HTTPRequestHandler : DBG]"x"\r\n", ##__VA_ARGS__);
 #define ERR(x, ...) std::printf("[HTTPRequestHandler : DBG]"x"\r\n", ##__VA_ARGS__);
--- a/HTTPServer.cpp	Sat Jun 01 06:24:43 2013 +0000
+++ b/HTTPServer.cpp	Sat Jun 01 16:49:17 2013 +0000
@@ -1,7 +1,7 @@
 #include "mbed.h"
 #include "HTTPServer.h"
 
-#define _DEBUG      1
+#define _DEBUG      0
 
 #ifdef _DEBUG
 DigitalOut led1(LED1);
@@ -89,7 +89,7 @@
 }
 
 
-int HTTPServer::poll()
+int HTTPServer::poll(bool blocking)
 {    
     int retval = -1;
     INFO("Listening for new connection requests.");
@@ -101,7 +101,7 @@
 #ifdef _DEBUG
     led4 = 1;   //  Indicate we are waiting for a new connection 
 #endif
-    m_pSvr->set_blocking(true); 
+    m_pSvr->set_blocking(blocking); 
     retval = m_pSvr->accept(Clnt);
     if (retval > 0) {
         // no connection availale yet, so just return
--- a/HTTPServer.h	Sat Jun 01 06:24:43 2013 +0000
+++ b/HTTPServer.h	Sat Jun 01 16:49:17 2013 +0000
@@ -133,10 +133,11 @@
         
         /** Performs the regular polling of the server component. Needs to be called cyclically.
         * The function will internally check whether new connections are requested by a client and will also poll all existing client connections.
+        * @param blocking : if true, 
         * @returns -1 if there was a problem. If 0 is returned, the latest request was served successfully and the server is
         * ready for processing the next request. Simply call \c poll as long as you want to serve new incoming requests.
         */
-        int poll();
+        int poll(bool blocking = true);
   
     private:
         /** The standard error handler function.