00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef _SOCKETS_AjpBaseSocket_H
00032 #define _SOCKETS_AjpBaseSocket_H
00033
00034 #include "TcpSocket.h"
00035 #include <map>
00036 #include "Utility.h"
00037
00038
00039 #ifdef SOCKETS_NAMESPACE
00040 namespace SOCKETS_NAMESPACE {
00041 #endif
00042
00043 class AjpBaseSocket : public TcpSocket
00044 {
00045 class Initializer
00046 {
00047 public:
00048 Initializer();
00049 virtual ~Initializer() {}
00050
00051 std::map<int, std::string> Method;
00052 std::map<int, std::string> Header;
00053 std::map<int, std::string> Attribute;
00054
00055 Utility::ncmap<int> ResponseHeader;
00056
00057 };
00058
00059 public:
00060 AjpBaseSocket(ISocketHandler& h);
00061
00062 void OnRawData(const char *buf, size_t sz);
00063
00064 virtual void OnHeader( short id, short len ) = 0;
00065 virtual void OnPacket( const char *buf, size_t sz ) = 0;
00066
00067 protected:
00068 unsigned char get_byte(const char *buf, int& ptr);
00069 bool get_boolean(const char *buf, int& ptr);
00070 short get_integer(const char *buf, int& ptr);
00071 std::string get_string(const char *buf, int& ptr);
00072
00073 void put_byte(char *buf, int& ptr, unsigned char zz);
00074 void put_boolean(char *buf, int& ptr, bool zz);
00075 void put_integer(char *buf, int& ptr, short zz);
00076 void put_string(char *buf, int& ptr, const std::string& zz);
00077
00078 static Initializer Init;
00079
00080 private:
00081 int m_state;
00082 int m_length;
00083 int m_ptr;
00084 char m_message[8192];
00085 };
00086
00087
00088 #ifdef SOCKETS_NAMESPACE
00089 }
00090 #endif
00091
00092 #endif // _SOCKETS_AjpBaseSocket_H
00093