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 HTTPServer by
Diff: HTTPConnection.h
- Revision:
- 0:7a2421e63e74
- Child:
- 1:6b7472d5e9ee
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPConnection.h Sun May 26 20:13:28 2013 +0000
@@ -0,0 +1,69 @@
+/* HTTPConnection.h */
+#ifndef __HTTPConnection_H__
+#define __HTTPConnection_H__
+
+#include "mbed.h"
+#include "TCPSocketConnection.h"
+
+#include <string>
+#include <map>
+
+enum HTTPRequestType
+{
+ HTTP_RT_GET,
+ HTTP_RT_POST,
+ HTTP_RT_PUT,
+ HTTP_RT_OPTIONS,
+ HTTP_RT_HEAD,
+ HTTP_RT_DELETE,
+ HTTP_RT_TRACE,
+ HTTP_RT_CONNECT
+};
+
+struct HTTPMessage
+{
+ HTTPRequestType request;
+ std::string uri;
+ std::string version;
+ std::map<string, string> headers;
+};
+
+/** class HTTPConnection, encapsulates one connection being made throught the HTTPServer
+ *
+ */
+class HTTPConnection {
+ public:
+ /** public constructor
+ *
+ */
+ HTTPConnection ();
+ ~HTTPConnection();
+
+ /** function to close this connection. To be called from internally.
+ */
+ void close();
+
+ /** query if this connection is closed and can be deleted.
+ @returns true if connection is closed.
+ */
+ bool is_closed();
+
+ /**
+ Polling function
+ @returns -1 if connection is not required anymore. Can happen if a fault occured or if the connection is not needed anymore.
+ */
+ int poll();
+
+ protected:
+
+ TCPSocketConnection m_Tcp;
+
+ HTTPMessage m_Msg;
+ int parse(const char *buffer);
+ int parseHeader(const char *buffer);
+ int receiveHeaders(const char* buffer, int nBuffSize);
+ int receiveLine(char* szLine, int nMaxLen, int nTimeout = -1, char szLineTerm = '\n');
+
+};
+
+#endif // __HTTPConnection_H__
\ No newline at end of file
