Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

dsHttpDaemon Class Reference

#include <dsHttpd.h>

Inheritance diagram for dsHttpDaemon:

dsDaemon SimpleHttpDaemon List of all members.

Public Methods

 dsHttpDaemon (char *server_root, int bind_port, char *daemon_name, int max_childs, int flags)
virtual ~dsHttpDaemon ()
virtual int reinit ()
void kill_running ()

Protected Methods

virtual int child_work ()
virtual int init_globals ()
virtual pid_t fork_child ()
virtual void shutdown_child ()
void http_request_headers (dsStrstream &src)
int end_of_header (dsStrstream &req)
bool parse_first_line (dsStrstream &src)
bool parse_header_line (dsStrstream &src)
virtual void http_common_headers (std::ostream &os)
 Contains parsed http header.

virtual void http_server_sign (std::ostream &os)
virtual int http_500 (const char *message=0)
virtual int http_501 (const char *method, const char *implemented="GET")
virtual int http_400 (const char *req_url)
virtual int http_403 (const char *req_url)
virtual int http_404 (const char *req_url)
virtual int http_200 (const char *mime_type, dsStrstream &body)
virtual int http_200 (const char *mime_type, int cont_length)
virtual void vhost_setup (dsStrstream &src)
virtual const char * content_type (const char *url)
virtual int process_request (dsStrstream &src)
void processPidFile ()
void addChild (pid_t npid)
void removeChild (pid_t npid)
int waitForFreeSlot (pid_t pid)

Protected Attributes

char * _server_root
 Chroot path.

int _bind_port
 Port to bind to.



void daemonize (dsDaemon *sd, int options=0)
void dsSafeSleep (int secs, int nsecs=0)
int DaemonFlags (char *str)
void SIGCHLD_hdl (int sig)
void SIGANY_hdl (int sig)
void SIGINT_hdl (int sig)

Constructor & Destructor Documentation

dsHttpDaemon::dsHttpDaemon char *    server_root,
int    bind_port,
char *    daemon_name,
int    max_childs,
int    flags

dsHttpDaemon::~dsHttpDaemon   [virtual]

Member Function Documentation

void dsDaemon::addChild pid_t    npid [protected, inherited]

int dsHttpDaemon::child_work   [protected, virtual]

This function does per child actions

Reimplemented from dsDaemon.

const char * dsHttpDaemon::content_type const char *    url [protected, virtual]

Extract url suffx and attempt to map it to content type

int dsHttpDaemon::end_of_header dsStrstream   req [protected]

pid_t dsHttpDaemon::fork_child   [protected, virtual]

fork child. Default function increase child counter and then fork. It's better to call return dsDaemon::fork_child() at the end of overloaded function. if overloaded function returns -1 (fork error) child will not be intialised.

Reimplemented from dsDaemon.

void dsHttpDaemon::http_common_headers std::ostream &    os [protected, virtual]

This function place daemon sign to bottom of error messages

Reimplemented in SimpleHttpDaemon.

void dsHttpDaemon::http_request_headers dsStrstream   src [protected]

void dsHttpDaemon::http_server_sign std::ostream &    os [protected, virtual]

This function add common headers to every response default implementation add local date only. Polite daemon should also add its name.

Reimplemented in SimpleHttpDaemon.

int dsHttpDaemon::init_globals   [protected, virtual]

Perform tasks after daemon detach, but before first fork all file handlers is closed to this point.

Reimplemented from dsDaemon.

void dsDaemon::kill_running   [inherited]

read pid file and kill running instance

bool dsHttpDaemon::parse_first_line dsStrstream   src [protected]

bool dsHttpDaemon::parse_header_line dsStrstream   src [protected]

int dsHttpDaemon::process_request dsStrstream   src [protected, virtual]

Do per-request work. All found http headers placed into hashtable two meta-headers added METHOD and URL Argument src points to start of data block

Reimplemented in SimpleHttpDaemon.

void dsDaemon::processPidFile   [protected, inherited]

int dsDaemon::reinit   [virtual, inherited]

Function to call from SIGHUP handler. Week point use it with care.

void dsDaemon::removeChild pid_t    npid [protected, inherited]

void dsHttpDaemon::shutdown_child   [protected, virtual]

This function called when child terminated wether by SIGTERM or normally

Reimplemented from dsDaemon.

void dsHttpDaemon::vhost_setup dsStrstream   src [protected, virtual]

Do additional initialisation just after request header parsed.

Reimplemented in SimpleHttpDaemon.

int dsDaemon::waitForFreeSlot pid_t    pid [protected, inherited]

Waits for free slot in child array, and returns number of found slot

Friends And Related Function Documentation

int DaemonFlags char *    str [friend, inherited]

Convert text reperesentation of daemon file into binary flags

void daemonize dsDaemon   sd,
int    options = 0
[friend, inherited]

Perform basic system tasks to become a daemon: close all handlers, allocate new process group and detach

  • sd pointer to dsDaemon object
  • options daemon flags

void dsSafeSleep int    secs,
int    nsecs = 0
[friend, inherited]

safe sleep: implement sleep by nanosleep or select timer (TODO), instead of using SIGALARM or sleep() to avoid possible interference with user application

void SIGANY_hdl int    sig [friend, inherited]

void SIGCHLD_hdl int    sig [friend, inherited]

void SIGINT_hdl int    sig [friend, inherited]

Member Data Documentation

int dsHttpDaemon::_bind_port [protected]

dsHashTable* dsHttpDaemon::_ht [protected]

char* dsHttpDaemon::_server_root [protected]

dsServerSocket* dsHttpDaemon::_ss [protected]

The documentation for this class was generated from the following files:
Generated on Mon May 16 18:27:00 2005 for libdms4 by doxygen1.3-rc2