A simple web server that can be bound to either the EthernetInterface or the WiflyInterface.

Dependents:   Smart-WiFly-WebServer WattEye X10Svr SSDP_Server

Revision:
2:a29c32190037
Parent:
1:54353af0d20a
Child:
3:17928786bdb5
--- a/SW_HTTPServer.h	Fri May 31 03:46:58 2013 +0000
+++ b/SW_HTTPServer.h	Sun Jun 02 18:32:05 2013 +0000
@@ -32,14 +32,24 @@
 /// @li query_string is any combination of name=value pairs
 /// @li fragment_id is a reference to an anchor on the page
 ///
+/// Feature request list:
 /// @todo make it non-blocking.
 /// @todo hunt down lengthy operations - there seems to be a long timeout somewhere.
+/// @todo parse the header similar to the query string, and then make
+///       those parameters accessible - perhaps like environment vars.
 /// @todo move part of the POST method handler to the registered handler, so
 ///       it can decide if it should allocate the needed memory.
+/// @todo Add password capability to some web pages
 /// @todo transform the pc serial interface to a log interface, which might
 ///       be more useful.
-/// @todo parse the header similar to the query string, and then make
-///       those parameters accessible - perhaps like environment vars.
+/// @todo Add ability to put WiFly in AP mode and then configuration pages
+///       to find and join a network.
+/// @todo Add ability to change/update SW in the WiFly module
+/// @todo Add ability to upload a new application to the mbed
+///
+/// History:
+/// @li 20130530 Initial version
+/// @li 20130601 Renamed ip_process to Poll
 ///
 /// @note Copyright © 2013 by Smartware Computing, all rights reserved.
 ///     Individuals may use this application for evaluation or non-commercial
@@ -62,15 +72,32 @@
         char * name;
         char * value;
     } namevalue;
+    
+    /**
+    * Indicates the purpose of the callback
+    */
+    typedef enum {
+        CONTENT_LENGTH_REQUEST, ///<!- ask the user if they wish to accept the data
+        DATA_TRANSFER,
+        SEND_PAGE,              ///<! the activated method should now send the page
+    } CallBackType;
 
     /** 
     * callback prototype for custom handler
     *
+    * This callback gets overloaded for a few purposes, which can be identified by the CallBackType parameter
+    * @li SEND_PAGE - the callback should now send the html page, using as many svr->send() as needed. 
+    *       When the callback returns, it should always indicate true.
+    * @li CONTENT_LENGTH_REQUEST - the server is asking the callback if it wants to receive the message,
+    *        which may require significant memory. If the request is accepted, true should be returned.
+    *        If the request is denied, false should be returned.
+    * 
     * @param svr is a handle to this class, so the callback has access to member functions
     * @param params is a pointer to an array of name value pairs
     * @paramcount is the number of parameters.
+    * @return true if command was accepted
     */
-    typedef void (* Handler)(HTTPServer * svr, const char * path, const namevalue *params, int paramcount);
+    typedef bool (* Handler)(HTTPServer * svr, CallBackType type, const char *path, const namevalue *params, int paramcount);
     
     /**
     * Create the HTTPServer object.
@@ -92,8 +119,10 @@
     /**
     * the process to call whenever there is free time, as this basically does
     * all the work to monitor for connections and handle replies.
+    *
+    * 20130601 Renamed from ip_process to Poll
     */
-    void ip_process();
+    void Poll();
     
     /**
     * Send a header back to the client and automatically appends a "\r\n". Each parameter must