Panda3D
http_request.h
1 #ifndef Http_Request_H_
2 #define Http_Request_H_
3 
4 class Http_Request;
5 extern std::set< Http_Request * > Global_WebRequests_pendingNotify;
6 
8 {
9 public:
10  Http_Request(SOCKET sck,Socket_Address &inaddr) : HttpConnection(sck,inaddr)
11  {
12  };
13 
14  ~Http_Request()
15  {
16  Global_WebRequests_pendingNotify.erase(this);
17  };
18  bool BuildPage( BufferedWriter_Growable &_writer, ParsedHttpRequest &parser)
19  {
20  Global_WebRequests_pendingNotify.insert((Http_Request *)this);
21 
22  _state = WAITING_TO_FINALIZE;
23  _Timer.ResetAll(Time_Clock::GetCurrentTime(),Time_Span(9999999,0));
24  return true;
25  };
26 
27  CloseState TryAndFinalize()
28  {
29  return ConnectionDoNotClose;
30  };
31 
32 PUBLISHED:
33 
34  std::string GetRequestType()
35  {
36  return _parser.GetRequestType();
37  }
38 
39  std::string GetRawRequest()
40  {
41  return _parser.GetRawRequest();
42  }
43 
44  std::string GetRequestURL()
45  {
46  return _parser.GetRequestURL();
47  }
48 
49  std::string GetSourceAddress()
50  {
51  return _MyAddress.get_ip_port();
52  }
53 
54  void AppendToResponse(const std::string &in)
55  {
56  _writer+=in;
57  }
58 
59 
60  void SendThisResponse(const std::string &in)
61  {
62  _writer+=in;
63  Finish();
64  }
65 
66  void Finish()
67  {
68  _Timer.ResetAll(Time_Clock::GetCurrentTime(),Time_Span(10,0));
69  _state = WRITING_DATA;
70  };
71  void Abort()
72  {
73  _state = ABORTING;
74  };
75 
76 
77  bool HasOption(std::string in)
78  {
79  const std::string * answer = _parser.GetOption(in);
80  if(answer != NULL)
81  return true;
82  return false;
83  }
84 
85  const char * GetOption(std::string in)
86  {
87  const std::string * answer = _parser.GetOption(in);
88  if(answer != NULL)
89  return answer->c_str();
90  return "";
91  }
92  std::string GetRequestOptionString()
93  {
94  return _parser.GetRequestOptionString();
95  }
96 
97  static bool HttpManager_Initialize( unsigned short port);
98  static Http_Request * HttpManager_GetARequest();
99 
100 public:
101  static TypeHandle get_class_type() {
102  return _type_handle;
103  }
104  static void init_type() {
105  HttpConnection::init_type();
106  register_type(_type_handle, "Http_Request",
107  HttpConnection::get_class_type());
108  }
109  virtual TypeHandle get_type() const {
110  return get_class_type();
111  }
112  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
113 
114 private:
115  static TypeHandle _type_handle;
116 };
117 
118 
119 
120 
121 
122 
123 #endif // Http_Request_H_
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
static Time_Clock GetCurrentTime()
The Default no param constructor.
Definition: time_clock.h:160