aboutsummaryrefslogtreecommitdiff
path: root/src/protocolhttp.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-10-04 10:46:46 +0000
committerMike Buland <eichlan@xagasoft.com>2007-10-04 10:46:46 +0000
commit86f9fbefa58d91e151190c969216c751573bc664 (patch)
tree4e13de2666bfb063964877986dc7b8d310714483 /src/protocolhttp.h
parentb3eef5b0b82c20a9f11868ba376f6bb2d94faae4 (diff)
downloadlibbu++-86f9fbefa58d91e151190c969216c751573bc664.tar.gz
libbu++-86f9fbefa58d91e151190c969216c751573bc664.tar.bz2
libbu++-86f9fbefa58d91e151190c969216c751573bc664.tar.xz
libbu++-86f9fbefa58d91e151190c969216c751573bc664.zip
Discovered that the Bu::Client::disconnect() function didn't do anything. That
has been fixed, it now safely disconnects after emptying the Client's outgoing buffer. Added some more helpers to Bu::FString. Added the beginings of ProtocolHttp using a new method for processing protocols that's based more strongly on an NFA state machine, this makes sense, but I never had the desire to actually try implementing it before. It's working pretty well.
Diffstat (limited to 'src/protocolhttp.h')
-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