Panda3D
 All Classes Functions Variables Enumerations
http_connection.h
1 #ifndef HttpConnection_H
2 #define HttpConnection_H
3 ////////////////////////////////////////////////////////////////////
4 ////////////////////////////////////////////////////////////////////
5 #include "parsedhttprequest.h"
6 #include "baseincomingset.h"
7 
8 #include "bufferedwriter_growable.h"
9 #include "http_bufferedreader.h"
10 
11 
12 class HttpConnection : public Socket_TCP
13 {
14 protected:
15  Http_BufferedReader _Reader;
17  Socket_Address _MyAddress;
18 
19  Time_Out _Timer;
20 
21  enum STATE_CONNECTIONS {
22  READING_HEADER =1,
23  READING_POST =2,
24  WAITING_TO_FINALIZE =3,
25  WRITING_DATA =4,
26  ABORTING = 5,
27  };
28 
29 
30  STATE_CONNECTIONS _state;
31 
32 
33  ParsedHttpRequest _parser;
34 
35  StrTargetBuffer _bodyDetail;
36  std::string _headerDetail;
37 
38  int CloseStateWriter(Time_Clock &currentTime);
39 
40 public:
41  virtual ~HttpConnection(void);
42  const Socket_Address & GetMyAddress(void);
43  virtual bool BuildPage( BufferedWriter_Growable &_writer, ParsedHttpRequest &parser) = 0;
44  HttpConnection(SOCKET sck,Socket_Address &inaddr) ;
45 
46  CloseState ProcessMessage(char * message,Time_Clock &currentTime);
47  int DoReadHeader(char * message, int buffersize,Time_Clock &currentTime);
48  int DoReadBody(char * message, int buffersize,Time_Clock &currentTime);
49  int ReadIt(char * message, int buffersize,Time_Clock &currentTime);
50  void Reset();
51 
52  virtual CloseState TryAndFinalize() { _state = WRITING_DATA; ;return ConnectionDoNotClose; };
53 
54  std::string GetFullmessage() { return _headerDetail + _bodyDetail; };
55 
56 public:
57  static TypeHandle get_class_type() {
58  return _type_handle;
59  }
60  static void init_type() {
61  Socket_TCP::init_type();
62  register_type(_type_handle, "HttpConnection",
63  Socket_TCP::get_class_type());
64  }
65  virtual TypeHandle get_type() const {
66  return get_class_type();
67  }
68  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
69 
70 private:
71  static TypeHandle _type_handle;
72 };
73 
74 
75 #endif // HttpConnection_H
76 
77 
78 
Base functionality for a TCP connected socket This class is pretty useless by itself but it does hide...
Definition: socket_tcp.h:15
A simple place to store and munipulate tcp and port address for communication layer.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85