GClasses
GClasses::GHttpServer Class Referenceabstract

Detailed Description

This class allows you to implement a simple HTTP daemon.

#include <GHttp.h>

Inheritance diagram for GClasses::GHttpServer:
GClasses::GDynamicPageServer

Public Member Functions

 GHttpServer (int nPort)
 
virtual ~GHttpServer ()
 
virtual GHttpConnectionmakeConnection (SOCKET s)=0
 This method should return a new instance of an object that inherrits from GHttpConnection. More...
 
bool process ()
 You should call this method constantly inside the main loop. It returns true if it did anything, and false if it didn't, so if it returns false you may want to sleep for a little while. More...
 
GTCPServersocket ()
 Returns a reference to the socket on which this server listens. More...
 

Static Public Member Functions

static bool parseFileParam (const char *pParams, size_t nParamsLen, const char **ppFilename, size_t *pFilenameLen, const unsigned char **ppFile, size_t *pFileLen)
 This is a rather hacky method that parses the parameters of a specific upload-file form. More...
 
static void unescapeUrl (char *szOut, const char *szIn, size_t nInLen)
 Unescapes a URL. (i.e. replace "%20" with " ", etc.). szOut should point to a buffer at least as big as szIn (including the null terminator). This will stop when it hits the null-terminator in szIn or when nInLen characters have been parsed. So if szIn is null-terminated, you can safely pass in a huge arbitrary value for nInLen. More...
 

Protected Member Functions

void beginRequest (GHttpConnection *pConn, int eType, const char *szIn)
 
virtual void onProcessLine (GHttpConnection *pConn, const char *szLine)
 
void onReceiveFullPostRequest (GHttpConnection *pConn)
 
void processHeaderLine (GHttpConnection *pConn, const char *szLine)
 
void processPostData (GHttpConnection *pConn, const unsigned char *pData, size_t nDataSize)
 
void sendNotModifiedResponse (GHttpConnection *pConn)
 
void sendResponse (GHttpConnection *pConn)
 

Protected Attributes

char * m_pReceiveBuf
 
GHttpServerSocket * m_pSocket
 
std::ostringstream m_stream
 

Constructor & Destructor Documentation

GClasses::GHttpServer::GHttpServer ( int  nPort)
virtual GClasses::GHttpServer::~GHttpServer ( )
virtual

Member Function Documentation

void GClasses::GHttpServer::beginRequest ( GHttpConnection pConn,
int  eType,
const char *  szIn 
)
protected
virtual GHttpConnection* GClasses::GHttpServer::makeConnection ( SOCKET  s)
pure virtual

This method should return a new instance of an object that inherrits from GHttpConnection.

virtual void GClasses::GHttpServer::onProcessLine ( GHttpConnection pConn,
const char *  szLine 
)
inlineprotectedvirtual
void GClasses::GHttpServer::onReceiveFullPostRequest ( GHttpConnection pConn)
protected
static bool GClasses::GHttpServer::parseFileParam ( const char *  pParams,
size_t  nParamsLen,
const char **  ppFilename,
size_t *  pFilenameLen,
const unsigned char **  ppFile,
size_t *  pFileLen 
)
static

This is a rather hacky method that parses the parameters of a specific upload-file form.

bool GClasses::GHttpServer::process ( )

You should call this method constantly inside the main loop. It returns true if it did anything, and false if it didn't, so if it returns false you may want to sleep for a little while.

void GClasses::GHttpServer::processHeaderLine ( GHttpConnection pConn,
const char *  szLine 
)
protected
void GClasses::GHttpServer::processPostData ( GHttpConnection pConn,
const unsigned char *  pData,
size_t  nDataSize 
)
protected
void GClasses::GHttpServer::sendNotModifiedResponse ( GHttpConnection pConn)
protected
void GClasses::GHttpServer::sendResponse ( GHttpConnection pConn)
protected
GTCPServer* GClasses::GHttpServer::socket ( )
inline

Returns a reference to the socket on which this server listens.

static void GClasses::GHttpServer::unescapeUrl ( char *  szOut,
const char *  szIn,
size_t  nInLen 
)
static

Unescapes a URL. (i.e. replace "%20" with " ", etc.). szOut should point to a buffer at least as big as szIn (including the null terminator). This will stop when it hits the null-terminator in szIn or when nInLen characters have been parsed. So if szIn is null-terminated, you can safely pass in a huge arbitrary value for nInLen.

Member Data Documentation

char* GClasses::GHttpServer::m_pReceiveBuf
protected
GHttpServerSocket* GClasses::GHttpServer::m_pSocket
protected
std::ostringstream GClasses::GHttpServer::m_stream
protected