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

SimpleHttpDaemon Class Reference

#include <httpd.h>

Inheritance diagram for SimpleHttpDaemon:

dsHttpDaemon dsDaemon List of all members.

Public Methods

 SimpleHttpDaemon (int max_childs, int flags)
virtual ~SimpleHttpDaemon ()
virtual int reinit ()
void kill_running ()

Protected Methods

virtual void http_common_headers (std::ostream &os)
 Contains parsed http header.

virtual void http_server_sign (std::ostream &os)
int outfile (const char *fname, size_t size, const char *mime_type)
int autoindex (const char *dirname)
virtual void vhost_setup (dsStrstream &src)
virtual int process_request (dsStrstream &src)
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 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 const char * content_type (const char *url)
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

SimpleHttpDaemon::SimpleHttpDaemon int    max_childs,
int    flags

SimpleHttpDaemon::~SimpleHttpDaemon   [virtual]

Member Function Documentation

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

int SimpleHttpDaemon::autoindex const char *    dirname [protected]

int dsHttpDaemon::child_work   [protected, virtual, inherited]

This function does per child actions

Reimplemented from dsDaemon.

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

Extract url suffx and attempt to map it to content type

int dsHttpDaemon::end_of_header dsStrstream   req [protected, inherited]

pid_t dsHttpDaemon::fork_child   [protected, virtual, inherited]

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 SimpleHttpDaemon::http_common_headers std::ostream &    os [protected, virtual]

This function place daemon sign to bottom of error messages

Reimplemented from dsHttpDaemon.

void dsHttpDaemon::http_request_headers dsStrstream   src [protected, inherited]

void SimpleHttpDaemon::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 from dsHttpDaemon.

int dsHttpDaemon::init_globals   [protected, virtual, inherited]

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

int SimpleHttpDaemon::outfile const char *    fname,
size_t    size,
const char *    mime_type

bool dsHttpDaemon::parse_first_line dsStrstream   src [protected, inherited]

bool dsHttpDaemon::parse_header_line dsStrstream   src [protected, inherited]

int SimpleHttpDaemon::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 from dsHttpDaemon.

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, inherited]

This function called when child terminated wether by SIGTERM or normally

Reimplemented from dsDaemon.

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

Do additional initialisation just after request header parsed.

Reimplemented from dsHttpDaemon.

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, inherited]

dsHashTable* dsHttpDaemon::_ht [protected, inherited]

char* dsHttpDaemon::_server_root [protected, inherited]

dsServerSocket* dsHttpDaemon::_ss [protected, inherited]

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