00001 #ifndef SimpleHttpd_h 00002 #define SimpleHttpd_h 00003 00004 #include <dsSmartException.h> 00005 #include <dsDaemon.h> 00006 #include <dsSocket.h> 00007 #include <dsHttpd.h> 00008 #include <dsLog.h> 00009 #include <dsStrstream.h> 00010 00011 #include <iostream> 00012 00013 #define DAEMON_NAME "dsSimpleHttpd" 00014 00015 /* per-host setup parameters */ 00016 struct HostInfo 00017 { 00018 char * doc_root; 00019 char * doc_index; 00020 int doc_autoindex; 00021 00022 HostInfo() 00023 { 00024 doc_root = 0; 00025 doc_index = 0; 00026 doc_autoindex = 0; 00027 } 00028 }; 00029 00030 class SimpleHttpDaemon: public dsHttpDaemon 00031 { 00032 int _enable_vhosts; 00033 00034 HostInfo* _hi; 00035 00036 protected: 00037 virtual void http_common_headers(std::ostream &os); 00038 virtual void http_server_sign(std::ostream &os); 00039 00040 int outfile(const char *fname, size_t size, const char* mime_type); 00041 int autoindex(const char *dirname); 00042 00043 virtual void vhost_setup(dsStrstream& src); 00044 virtual int process_request(dsStrstream& src); 00045 00046 public: 00047 SimpleHttpDaemon(int max_childs, int flags); 00048 virtual ~SimpleHttpDaemon(); 00049 }; 00050 00051 #endif