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
00032
00033 #ifndef _SOCKETS_AjpBaseSocket_H
00034 #define _SOCKETS_AjpBaseSocket_H
00035
00036 #include "TcpSocket.h"
00037 #include <map>
00038 #include "Utility.h"
00039
00040
00041 #ifdef SOCKETS_NAMESPACE
00042 namespace SOCKETS_NAMESPACE {
00043 #endif
00044
00045 class AjpBaseSocket : public TcpSocket
00046 {
00047 class Initializer
00048 {
00049 public:
00050 Initializer();
00051 virtual ~Initializer() {}
00052
00053 std::map<int, std::string> Method;
00054 std::map<int, std::string> Header;
00055 std::map<int, std::string> Attribute;
00056
00057 Utility::ncmap<int> ResponseHeader;
00058
00059 };
00060
00061 public:
00062 AjpBaseSocket(ISocketHandler& h);
00063
00064 void OnRawData(const char *buf, size_t sz);
00065
00066 virtual void OnHeader( short id, short len ) = 0;
00067 virtual void OnPacket( const char *buf, size_t sz ) = 0;
00068
00069 protected:
00070 unsigned char get_byte(const char *buf, int& ptr);
00071 bool get_boolean(const char *buf, int& ptr);
00072 short get_integer(const char *buf, int& ptr);
00073 std::string get_string(const char *buf, int& ptr);
00074
00075 void put_byte(char *buf, int& ptr, unsigned char zz);
00076 void put_boolean(char *buf, int& ptr, bool zz);
00077 void put_integer(char *buf, int& ptr, short zz);
00078 void put_string(char *buf, int& ptr, const std::string& zz);
00079
00081 void reset();
00082
00083 static Initializer Init;
00084
00085 private:
00086 int m_state;
00087 int m_length;
00088 int m_ptr;
00089 char m_message[8192];
00090 };
00091
00092
00093 #ifdef SOCKETS_NAMESPACE
00094 }
00095 #endif
00096
00097 #endif // _SOCKETS_AjpBaseSocket_H
00098