Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SW_HTTPServer by
Diff: SW_HTTPServer.h
- Revision:
- 22:55974de690c1
- Parent:
- 21:660143f20b04
--- a/SW_HTTPServer.h Thu Sep 26 23:47:50 2013 +0000 +++ b/SW_HTTPServer.h Thu Oct 10 13:44:07 2013 +0000 @@ -51,7 +51,7 @@ /// or signaling outputs. /// /// @code -/// HTTPServer svr(&wifly, HTTP_SERVER_PORT, "/local/", 15, 30, 10, &pc); +/// HTTPServer svr(&wifly, HTTP_SERVER_PORT, "/local", 15, 30, 10, &pc); /// svr.RegisterHandler("/dyn1", SimpleDynamicPage); /// while (true) /// { @@ -187,7 +187,7 @@ */ typedef enum CALLBACKTYPE { CONTENT_LENGTH_REQUEST, ///< ask the client if they wish to accept the data, typically from a POST event - DATA_TRANSFER, ///< not currently used, may allow "chunking" the data to the client + DATA_TRANSFER, ///< used when submitting a file via a form SEND_PAGE, ///< the activated method should now send the page } CallBackType; @@ -195,14 +195,23 @@ * This is the prototype for custom handlers that are activated via a callback * * This callback gets overloaded for a few purposes, which can be identified by the \see CallBackType parameter + * @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. + * @li DATA_TRANSFER - the server is handing off a large body of data, which was accepted based + * on the CONTENT_LENGTH_REQUEST callback. The data is now available for processing. + * The callback should return true to continue the processing. * @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. + * + * @note The queryParams pointer purpose depends on the callback type. + * For CONTENT_LENGTH_REQUEST, the pointer points to the name=value pairs from the + * header. + * For DATA_TRANSFER, the pointer points to the start of the actual data. + * For SEND_PAGE, * * @param svr is a handle to this class, so the callback has access to member functions - * @param queryParams is a pointer to an array of name value pairs + * @param queryParams is a pointer based on the callback type. * @queryParamCount is the number of parameters. * @return true if command was accepted */ @@ -231,6 +240,20 @@ ~HTTPServer(); /** + * Get the path to the webroot, for applications that need to + * reference the file system relative to that point. + * + * @note The returned value may not be exactly as set at instantiation + * as trailing '/' were removed (unless the web root == "/"). + * e.g. "/msc/web/" becomes "/msc/web" + * + * @returns pointer to the webroot string. + */ + const char * GetWebRoot() { + return (const char *)webroot; + }; + + /** * The process to call whenever there is free time, as this basically does * all the work to monitor for connections and handle replies. *