aboutsummaryrefslogtreecommitdiff
path: root/src/protocolhttp.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/protocolhttp.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/protocolhttp.h b/src/protocolhttp.h
new file mode 100644
index 0000000..e10cb23
--- /dev/null
+++ b/src/protocolhttp.h
@@ -0,0 +1,63 @@
1#ifndef BU_PROTOCOL_HTTP_H
2#define BU_PROTOCOL_HTTP_H
3
4#include <stdint.h>
5#include <sys/types.h>
6
7#include "bu/protocol.h"
8#include "bu/client.h"
9#include "bu/fstring.h"
10
11namespace Bu
12{
13 /**
14 *
15 */
16 class ProtocolHttp : public Protocol
17 {
18 public: /* Types */
19 typedef Bu::List<Bu::FString> TokenList;
20
21 public: /* Interface */
22 ProtocolHttp();
23 virtual ~ProtocolHttp();
24
25 virtual void onNewConnection( Bu::Client *pClient );
26 virtual void onNewData( Bu::Client *pClient );
27
28 private:
29 enum TokenType
30 {
31 ttOutOfData,
32 ttString,
33 ttNewline,
34 ttDoubleNewline,
35 ttSeperator
36 };
37 /**
38 * Read an HTTP line, this is up to the first CRLF that isn't followed
39 * by a continuation character, converting it to one line as it reads.
40 *@param line All data read will be appended to line, even if no
41 * end-of-line is read.
42 *@returns True if an end-of-line is read and the line should be
43 * processed, false if the end-of-line has not been reached, and more
44 * data needs to be read before this operation can continue.
45 */
46 TokenType getToken( Bu::FString &line );
47 bool isWS( char buf );
48 bool isSeperator( char buf );
49
50 private: /* state */
51 Bu::Client *pClient;
52 TokenList lTokens;
53
54 int iState;
55
56 Bu::FString sMethod;
57 Bu::FString sPath;
58 int iMajor;
59 int iMinor;
60 };
61}
62
63#endif