Panda3D
 All Classes Functions Variables Enumerations
http_request.h
00001 #ifndef  Http_Request_H_
00002 #define  Http_Request_H_
00003 
00004 class Http_Request;
00005 extern std::set< Http_Request * >                       Global_WebRequests_pendingNotify;
00006  
00007 class Http_Request : public HttpConnection
00008 {
00009 public:
00010     Http_Request(SOCKET sck,Socket_Address &inaddr) : HttpConnection(sck,inaddr) 
00011     {
00012     };
00013 
00014     ~Http_Request() 
00015     {
00016         Global_WebRequests_pendingNotify.erase(this);
00017     };
00018     bool BuildPage( BufferedWriter_Growable &_writer, ParsedHttpRequest  &parser)
00019     {
00020         Global_WebRequests_pendingNotify.insert((Http_Request *)this);
00021 
00022         _state = WAITING_TO_FINALIZE;
00023         _Timer.ResetAll(Time_Clock::GetCurrentTime(),Time_Span(9999999,0));
00024         return true;
00025     };
00026 
00027     CloseState      TryAndFinalize()  
00028     {
00029         return  ConnectionDoNotClose;
00030     };
00031 
00032 PUBLISHED:
00033 
00034     std::string GetRequestType() 
00035     {
00036         return _parser.GetRequestType();
00037     }
00038 
00039     std::string GetRawRequest()
00040     {
00041         return _parser.GetRawRequest();
00042     }
00043 
00044     std::string GetRequestURL()
00045     {
00046         return _parser.GetRequestURL();
00047     }
00048 
00049     std::string GetSourceAddress() 
00050     {
00051         return _MyAddress.get_ip_port();
00052     }
00053 
00054     void   AppendToResponse(const std::string &in)
00055     {
00056         _writer+=in;
00057     }
00058 
00059 
00060     void SendThisResponse(const std::string &in)
00061     {
00062         _writer+=in;
00063         Finish();
00064     }
00065 
00066     void Finish()  
00067     {    
00068         _Timer.ResetAll(Time_Clock::GetCurrentTime(),Time_Span(10,0));
00069         _state  =  WRITING_DATA; 
00070     };
00071     void Abort()   
00072     {
00073         _state =   ABORTING; 
00074     };
00075 
00076 
00077     bool HasOption(std::string in)
00078     {
00079         const std::string * answer = _parser.GetOption(in);
00080         if(answer != NULL)
00081        return true;
00082         return false;
00083     }
00084 
00085     const char * GetOption(std::string in)
00086     {
00087         const std::string * answer = _parser.GetOption(in);
00088         if(answer != NULL)
00089        return answer->c_str();
00090         return "";
00091     }
00092     std::string   GetRequestOptionString()
00093     {
00094         return _parser.GetRequestOptionString();
00095     }
00096 
00097    static bool HttpManager_Initialize( unsigned short port);
00098    static Http_Request * HttpManager_GetARequest();
00099 
00100 public:
00101   static TypeHandle get_class_type() {
00102     return _type_handle;
00103   }
00104   static void init_type() {
00105     HttpConnection::init_type();
00106     register_type(_type_handle, "Http_Request",
00107                   HttpConnection::get_class_type());
00108   }
00109   virtual TypeHandle get_type() const {
00110     return get_class_type();
00111   }
00112   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00113 
00114 private:
00115   static TypeHandle _type_handle;
00116 };
00117 
00118 
00119 
00120 
00121 
00122 
00123 #endif  // Http_Request_H_
 All Classes Functions Variables Enumerations