#include <dsHttpd.h>
Inheritance diagram for dsHttpDaemon:
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 | |
dsServerSocket * | _ss |
char * | _server_root |
Chroot path. | |
int | _bind_port |
Port to bind to. | |
dsHashTable * | _ht |
Friends | |
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) |
|
|
|
|
|
|
|
This function does per child actions Reimplemented from dsDaemon. |
|
Extract url suffx and attempt to map it to content type |
|
|
|
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. |
|
This function place daemon sign to bottom of error messages Reimplemented in SimpleHttpDaemon. |
|
|
|
This function add common headers to every response default implementation add local date only. Polite daemon should also add its name. Reimplemented in SimpleHttpDaemon. |
|
Perform tasks after daemon detach, but before first fork all file handlers is closed to this point. Reimplemented from dsDaemon. |
|
read pid file and kill running instance |
|
|
|
|
|
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. |
|
|
|
Function to call from SIGHUP handler. Week point use it with care. |
|
|
|
This function called when child terminated wether by SIGTERM or normally Reimplemented from dsDaemon. |
|
Do additional initialisation just after request header parsed. Reimplemented in SimpleHttpDaemon. |
|
Waits for free slot in child array, and returns number of found slot |
|
Convert text reperesentation of daemon file into binary flags |
|
Perform basic system tasks to become a daemon: close all handlers, allocate new process group and detach
|
|
safe sleep: implement sleep by nanosleep or select timer (TODO), instead of using SIGALARM or sleep() to avoid possible interference with user application |
|
|
|
|
|
|
|
|
|
|
|
|
|
|