GClasses
GClasses::GDynamicPageConnection Class Referenceabstract

#include <GDynamicPage.h>

Inheritance diagram for GClasses::GDynamicPageConnection:
GClasses::GHttpConnection GClasses::GTCPConnection

Public Member Functions

 GDynamicPageConnection (SOCKET sock, GDynamicPageServer *pServer)
 
virtual ~GDynamicPageConnection ()
 
virtual void doGet (std::ostream &response)
 The primary purpose of this method is to push a response into pResponse. Typically this method will call SetHeaders. More...
 
virtual void doPost (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.) More...
 
- Public Member Functions inherited from GClasses::GHttpConnection
 GHttpConnection (SOCKET sock)
 General-purpose constructor. More...
 
virtual ~GHttpConnection ()
 
void reset ()
 Clear all the buffers in this object. More...
 
void setContentType (const char *szContentType)
 Specify the type of the content that is being sent to the client. More...
 
void setCookie (const char *szPayload, bool bPersist)
 Specify a cookie to send to the client with this response. More...
 
void setModifiedTime (time_t t)
 Sets the date (modified time) to be sent with the file so the client can cache it. More...
 
- Public Member Functions inherited from GClasses::GTCPConnection
 GTCPConnection (SOCKET sock)
 
virtual ~GTCPConnection ()
 
in_addr ipAddr ()
 Returns the client's IP address for this connection. (You can use inet_ntoa to convert the value this returns to a string.) More...
 
void setSocket (SOCKET sock)
 Sets the socket for this connection. More...
 
SOCKET socket ()
 Returns the socket associated with this connection. More...
 

Protected Member Functions

GDynamicPageSessionestablishSession ()
 
virtual void handleRequest (GDynamicPageSession *pSession, std::ostream &response)=0
 This method is called by doGet or doPost when a client requests something from the server. More...
 
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. More...
 
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. More...
 
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. More...
 

Static Protected Member Functions

static const char * extensionToMimeType (const char *szFilename)
 Determines an appropriate mime type for the given filename based on its extension. (Currently only recognizes a very small number of extensions.) More...
 

Protected Attributes

GDynamicPageServerm_pServer
 
- Protected Attributes inherited from GClasses::GTCPConnection
SOCKET m_sock
 

Additional Inherited Members

- Public Types inherited from GClasses::GHttpConnection
- Public Attributes inherited from GClasses::GHttpConnection
bool m_bPersistCookie
 
RequestType m_eRequestType
 
time_t m_modifiedTime
 
size_t m_nContentLength
 
size_t m_nPos
 
char * m_pContent
 
char * m_pPostBuffer
 
char m_szContentType [MAX_MIME_LEN]
 
char m_szCookieIncoming [MAX_COOKIE_SIZE]
 
char m_szCookieOutgoing [MAX_COOKIE_SIZE]
 
char m_szDate [MAX_DATE_LEN]
 
char m_szLine [MAX_HEADER_LEN]
 
char m_szParams [MAX_URL_LEN]
 
char m_szUrl [MAX_URL_LEN]
 

Constructor & Destructor Documentation

GClasses::GDynamicPageConnection::GDynamicPageConnection ( SOCKET  sock,
GDynamicPageServer pServer 
)
virtual GClasses::GDynamicPageConnection::~GDynamicPageConnection ( )
virtual

Member Function Documentation

virtual void GClasses::GDynamicPageConnection::doGet ( std::ostream &  response)
virtual

The primary purpose of this method is to push a response into pResponse. Typically this method will call SetHeaders.

Implements GClasses::GHttpConnection.

virtual void GClasses::GDynamicPageConnection::doPost ( std::ostream &  response)
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::GHttpConnection.

GDynamicPageSession* GClasses::GDynamicPageConnection::establishSession ( )
protected
static const char* GClasses::GDynamicPageConnection::extensionToMimeType ( const char *  szFilename)
staticprotected

Determines an appropriate mime type for the given filename based on its extension. (Currently only recognizes a very small number of extensions.)

virtual void GClasses::GDynamicPageConnection::handleRequest ( GDynamicPageSession pSession,
std::ostream &  response 
)
protectedpure virtual

This method is called by doGet or doPost when a client requests something from the server.

virtual bool GClasses::GDynamicPageConnection::hasBeenModifiedSince ( const char *  szUrl,
const char *  szDate 
)
protectedvirtual

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::GHttpConnection.

void GClasses::GDynamicPageConnection::sendFile ( const char *  szMimeType,
const char *  szFilename,
std::ostream &  response 
)
protected
void GClasses::GDynamicPageConnection::sendFileSafe ( const char *  szJailPath,
const char *  localPath,
std::ostream &  response 
)
protected

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.

virtual void GClasses::GDynamicPageConnection::setHeaders ( const char *  szUrl,
const char *  szParams 
)
protectedvirtual

This method should set the content type and the date headers, and any other headers deemed necessary.

Implements GClasses::GHttpConnection.

Member Data Documentation

GDynamicPageServer* GClasses::GDynamicPageConnection::m_pServer
protected