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

Dependents:   Smart-WiFly-WebServer WattEye X10Svr SSDP_Server

Revision:
48:078adbe279ac
Parent:
46:eaa86d48be6f
Child:
49:cd391662f254
--- a/SW_HTTPServer.h	Sun Feb 05 18:52:21 2017 +0000
+++ b/SW_HTTPServer.h	Sat Apr 08 19:39:51 2017 +0000
@@ -99,6 +99,8 @@
 ///     between the user-code and the server.
 ///
 /// History (TO-Done):
+/// @li 20170408 Added another optional parameter to the constructor to control the
+///       blocking time when Poll() is called.
 /// @li 20140913 Removed the relationship to the Wifly module, which caused an API change
 ///       in the constructor by elimination of the first parameter.
 /// @li 20140913 parses the header similar to the query string, and then makes
@@ -275,13 +277,13 @@
     *       For DATA_TRANSFER, the pointer points to the start of the actual data.
     *       For SEND_PAGE, ... <to be determined>
     *
-    * @param svr is a handle to this class, so the callback has access to member functions
-    * @param type is the callback type @see CallBackType
-    * @param path is the pointer to a large block of information being transferred. This pointer
+    * @param[in] svr is a handle to this class, so the callback has access to member functions
+    * @param[in] type is the callback type @see CallBackType
+    * @param[in] path is the pointer to a large block of information being transferred. This pointer
     *        references a dynamically managed resource, so any information of value must be 
     *        extracted from here, and not referenced into this memory space.
-    * @param queryParams is a pointer based on the callback type.
-    * @param count is the number of items - for type = CONTENT_LENGTH_REQUEST this is the number of 
+    * @param[in] queryParams is a pointer based on the callback type.
+    * @param[in] count is the number of items - for type = CONTENT_LENGTH_REQUEST this is the number of 
     *        name=value pars in the queryParams parameter, and for the DATA_TRANSFER this is the 
     *        number of bytes being passed in the path parameters.
     * @return one of the @see CallBackResults signals indicating error or successes
@@ -292,22 +294,24 @@
     /**
     * Create the HTTPServer object.
     *
-    * @param port is the optional parameter for the port number to use, default is 80.
-    * @param webroot is a file system path to the root folder for the web space. If any trailing '/'
+    * @param[in] port is the optional parameter for the port number to use, default is 80.
+    * @param[in] webroot is a file system path to the root folder for the web space. If any trailing '/'
     *        is included (e.g. "/web/path/") it will be removed (to "/web/path").
-    * @param maxheaderParams defines the maximum number of parameters to extract from a header 
+    * @param[in] maxheaderParams defines the maximum number of parameters to extract from a header 
     *        (Host: 192..\r\nConnection: keep-alive\r\n...)
-    * @param maxqueryParams defines the maximum number of query parameters to a dynamic function 
+    * @param[in] maxqueryParams defines the maximum number of query parameters to a dynamic function 
     *        (and the memory to support them).
-    * @param maxdynamicpages defines the maximum number of dynamic pages that can be registered.
-    * @param pc is the serial port for debug information (I should transform this to a log interface)
-    * @param allocforheader is the memory allocation to support the largest expected header from a client
-    * @param allocforfile is the memory allocation to support sending a file to the client. This is 
+    * @param[in] maxdynamicpages defines the maximum number of dynamic pages that can be registered.
+    * @param[in] pc is the serial port for debug information (I should transform this to a log interface)
+    * @param[in] allocforheader is the memory allocation to support the largest expected header from a client
+    * @param[in] allocforfile is the memory allocation to support sending a file to the client. This is 
     *        typically sized to fit an ethernet frame.
+    * @param[in] blockingtime is the time that the Poll process will pause, waiting for input.
     */
     HTTPServer(int port = 80, const char * webroot = "/", int maxheaderParams = 15, 
         int maxqueryParams = 30, int maxdynamicpages = 10,
-        PC * pc = NULL, int _allocforheader = MAX_HEADER_SIZE, int _allocforfile = FILESEND_BUF_SIZE);
+        PC * pc = NULL, int _allocforheader = MAX_HEADER_SIZE, int _allocforfile = FILESEND_BUF_SIZE,
+        int blockingtime = 10);
 
     /**
     * Destructor, which can clean up memory.
@@ -378,6 +382,8 @@
     *
     * Activate this API as often as you can, typically from the loop in main.
     *
+    * @note This API will pause execution for the "blocking time" value configured
+    *       in the constructor.
     */
     void Poll();
 
@@ -669,9 +675,8 @@
     /**
     * Get a value from the http header, if it exists.
     *
-    * @param hdr is the string to search for (e.g. "Content-Length")
-    *
-    * @returns[in] pointer to the value associated with that header.
+    * @param[in] hdr is the string to search for (e.g. "Content-Length")
+    * @returns pointer to the value associated with that header.
     * @returns NULL if the header is not found.
     */
     const char * GetHeaderValue(const char * hdr);
@@ -748,8 +753,8 @@
     * take the time when the performance measurement started. It locally
     * accesses the current time to measure the elapsed.
     *
-    * @param param is the performance parameter to update
-    * @param value is the reference time.
+    * @param[in] param is the performance parameter to update
+    * @param[in] value is the reference time.
     * @returns the current time which may be used as the reference time
     *          for further measurements.
     */
@@ -775,12 +780,12 @@
     *  The parameter of interest follows the needle, and may be ' ' delimited
     *  Can damage haystack while processing it.
     *
-    * @param haystack is the record to search
-    * @param needle is the text to search for, which precedes the text to return
-    * @param string is the text following the needle
+    * @param[in] haystack is the record to search
+    * @param[in] needle is the text to search for, which precedes the text to return
+    * @param[out] string is the text following the needle
     * @return true if it extracted something successfully
     */
-    bool Extract(char * rec, char * needle, char ** string);
+    bool Extract(char * haystack, char * needle, char ** string);
 
     void SendResponse();
     HTTPServer::CallBackResults ParseHeader(char * bPtr);