GClasses
|
#include <GDynamicPage.h>
Public Member Functions | |
GDynamicPageServer (int port, GRand *pRand) | |
virtual | ~GDynamicPageServer () |
virtual void | handleRequest (const char *szUrl, const char *szParams, int nParamsLen, GDynamicPageSession *pSession, std::ostream &response)=0 |
virtual void | onStateChange () |
virtual void | onEverySixHours () |
virtual void | onShutDown () |
void | go () |
void | shutDown () |
void | flushSessions () |
const char * | myAddress () |
Returns the account if the password is correct. Returns NULL if not. | |
void | setDaemonSalt (const char *szSalt) |
const char * | daemonSalt () |
const char * | passwordSalt () |
void | sendFile (const char *szMimeType, const char *szFilename, std::ostream &response) |
void | sendFileSafe (const char *szJailPath, const char *localPath, std::ostream &response) |
Concatenates szJailPath+szLocalPath, and makes sure that the result is within szJailPath, then it automatically determines the mime type from the extension, and sends the file. | |
GRand * | prng () |
void | redirect (std::ostream &response, const char *szUrl) |
Protected Member Functions | |
virtual void | doGet (const char *szUrl, const char *szParams, size_t nParamsLen, const char *szCookie, std::ostream &response) |
The primary purpose of this method is to push a response into pResponse. Typically this method will call SetHeaders. | |
virtual void | doPost (const char *szUrl, unsigned char *pData, size_t nDataSize, const char *szCookie, std::ostream &response) |
This method takes ownership of pData. Don't forget to delete it. When the POST is caused by an HTML form, it's common for this method to just call DoGet (passing pData for szParams) and then delete pData. (For convenience, a '\0' is already appended at the end of pData.) | |
virtual bool | hasBeenModifiedSince (const char *szUrl, const char *szDate) |
This is called when the client does a conditional GET. It should return true if you wish to re-send the file, and DoGet will be called. | |
virtual void | setHeaders (const char *szUrl, const char *szParams) |
This method should set the content type and the date headers, and any other headers deemed necessary. | |
GDynamicPageSession * | establishSession (const char *szCookie) |
void | doMaintenance () |
void | computePasswordSalt () |
Protected Attributes | |
GRand * | m_pRand |
bool | m_bKeepGoing |
std::map< unsigned long long, GDynamicPageSession * > | m_sessions |
char * | m_szMyAddress |
char | m_daemonSalt [16] |
char | m_passwordSalt [16] |
GClasses::GDynamicPageServer::GDynamicPageServer | ( | int | port, |
GRand * | pRand | ||
) |
virtual GClasses::GDynamicPageServer::~GDynamicPageServer | ( | ) | [virtual] |
void GClasses::GDynamicPageServer::computePasswordSalt | ( | ) | [protected] |
const char* GClasses::GDynamicPageServer::daemonSalt | ( | ) |
virtual void GClasses::GDynamicPageServer::doGet | ( | const char * | szUrl, |
const char * | szParams, | ||
size_t | nParamsLen, | ||
const char * | szCookie, | ||
std::ostream & | response | ||
) | [protected, virtual] |
The primary purpose of this method is to push a response into pResponse. Typically this method will call SetHeaders.
Implements GClasses::GHttpServer.
void GClasses::GDynamicPageServer::doMaintenance | ( | ) | [protected] |
virtual void GClasses::GDynamicPageServer::doPost | ( | const char * | szUrl, |
unsigned char * | pData, | ||
size_t | nDataSize, | ||
const char * | szCookie, | ||
std::ostream & | response | ||
) | [protected, virtual] |
This method takes ownership of pData. Don't forget to delete it. When the POST is caused by an HTML form, it's common for this method to just call DoGet (passing pData for szParams) and then delete pData. (For convenience, a '\0' is already appended at the end of pData.)
Implements GClasses::GHttpServer.
GDynamicPageSession* GClasses::GDynamicPageServer::establishSession | ( | const char * | szCookie | ) | [protected] |
void GClasses::GDynamicPageServer::flushSessions | ( | ) |
void GClasses::GDynamicPageServer::go | ( | ) |
virtual void GClasses::GDynamicPageServer::handleRequest | ( | const char * | szUrl, |
const char * | szParams, | ||
int | nParamsLen, | ||
GDynamicPageSession * | pSession, | ||
std::ostream & | response | ||
) | [pure virtual] |
virtual bool GClasses::GDynamicPageServer::hasBeenModifiedSince | ( | const char * | szUrl, |
const char * | szDate | ||
) | [protected, virtual] |
This is called when the client does a conditional GET. It should return true if you wish to re-send the file, and DoGet will be called.
Implements GClasses::GHttpServer.
const char* GClasses::GDynamicPageServer::myAddress | ( | ) |
Returns the account if the password is correct. Returns NULL if not.
virtual void GClasses::GDynamicPageServer::onEverySixHours | ( | ) | [inline, virtual] |
virtual void GClasses::GDynamicPageServer::onShutDown | ( | ) | [inline, virtual] |
virtual void GClasses::GDynamicPageServer::onStateChange | ( | ) | [inline, virtual] |
const char* GClasses::GDynamicPageServer::passwordSalt | ( | ) |
GRand* GClasses::GDynamicPageServer::prng | ( | ) | [inline] |
void GClasses::GDynamicPageServer::redirect | ( | std::ostream & | response, |
const char * | szUrl | ||
) |
void GClasses::GDynamicPageServer::sendFile | ( | const char * | szMimeType, |
const char * | szFilename, | ||
std::ostream & | response | ||
) |
void GClasses::GDynamicPageServer::sendFileSafe | ( | const char * | szJailPath, |
const char * | localPath, | ||
std::ostream & | response | ||
) |
Concatenates szJailPath+szLocalPath, and makes sure that the result is within szJailPath, then it automatically determines the mime type from the extension, and sends the file.
void GClasses::GDynamicPageServer::setDaemonSalt | ( | const char * | szSalt | ) |
virtual void GClasses::GDynamicPageServer::setHeaders | ( | const char * | szUrl, |
const char * | szParams | ||
) | [protected, virtual] |
This method should set the content type and the date headers, and any other headers deemed necessary.
Implements GClasses::GHttpServer.
void GClasses::GDynamicPageServer::shutDown | ( | ) |
bool GClasses::GDynamicPageServer::m_bKeepGoing [protected] |
char GClasses::GDynamicPageServer::m_daemonSalt[16] [protected] |
char GClasses::GDynamicPageServer::m_passwordSalt[16] [protected] |
GRand* GClasses::GDynamicPageServer::m_pRand [protected] |
std::map<unsigned long long, GDynamicPageSession*> GClasses::GDynamicPageServer::m_sessions [protected] |
char* GClasses::GDynamicPageServer::m_szMyAddress [protected] |