Single instance HTTP Server using WiFly Interface.
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.
REV5: - added support for basic RPC GET request functionality.
REV4: - added argument parsing from the request uri. - documentation extended and updated.
--- a/HTTPConnection.h Wed Jun 05 23:39:24 2013 +0000 +++ b/HTTPConnection.h Wed Jun 26 21:12:42 2013 +0000 @@ -24,7 +24,6 @@ #define __HTTPConnection_H__ #include "mbed.h" -#include "TCPSocketConnection.h" #include <string> #include <map> @@ -87,20 +86,12 @@ */ bool is_closed(); - /** Polling function for the connection. - * @returns -1 if connection is not required anymore. In the current version of this library this should be the normal case. This may change in future versions. - */ - int poll(); - protected: /** Function to close this connection. To be called from internally. */ void close(); - - friend class HTTPServer; - TCPSocketConnection m_Tcp; HTTPMessage m_Msg; /** parse a HTTP request line from the content of the buffer. @@ -108,22 +99,7 @@ * @returns -1 if the request is invalid or 0 if the request is valid */ int parse(char *buffer); - - /** parses the received string in \c buffer for HTTP request headers. - * @param buffer : buffer which contains the string to parse for headers. - * @returns -1 in case of an error, otherwise returns 0 - */ - int parseHeader(char *buffer); int receiveHeaders(const char* buffer, int nBuffSize); - - /** Function which receives a line from the current Socket - * @param szline : will contain one line received from the socket - * @param nMaxLen : the size of the buffer. If the line is longer than the buffer the line is cropped at the end. - * @param nTimeout : if the timeout elapses, only the portion that has been received within this time will be returned. - * @param szLineTerm : the \c end-of-line character to be used to detect the end of the line. - * @returns -1 in case of an error or timeout, -2 in case of an empty line or the number of received characters. - */ - int receiveLine(char* szLine, int nMaxLen, int nTimeout = -1, char szLineTerm = '\n'); /** parse the receoved \c uri_string for arguments which will be stored in the \c args map.