Single instance HTTP Server using WiFly Interface.

Dependents:   WiFlyHTTPServerSample MultiThreadingHTTPServer

Embed: (wiki syntax)

« Back to documentation index

HTTPFsRequestHandler Class Reference

class HTTPFsRequestHandler serves requests with file-system objects More...

#include <FsHandler.h>

Inherits HTTPRequestHandler.

Public Member Functions

 HTTPFsRequestHandler (const char *rootPath, const char *localPath, HTTPConnection::HTTPMessage &Msg)
 constructor for HTTPFsRequestHandler object and stores the request related data locally.
virtual ~HTTPFsRequestHandler ()
 Destructor.
virtual int handleGetRequest ()
 Handler function to serve GET requests.
virtual int handlePutRequest ()
 Handler function to serve PUT requests.
virtual int handlePostRequest ()
 Handler function to serve POST requests.
int parseUriArgs (string uri, map< string, string > &args)
 Parse a uri string for uri file name and argument:value pairs.
virtual void handleRequest ()
 Handler function which will be used by the HTTPServer to serve requests.
virtual void handleError (int errorCode, HTTPHeaders *header=NULL)
 Handler function which will handle errors and return errors correctly.
void startResponse (int returnCode, long nLen, HTTPHeaders *header=NULL)
 Function sends the response header which consists of the return code and the headers section the response header also contains the length (in bytes) of the body.

Static Public Member Functions

static HTTPRequestHandlercreate (const char *rootPath, const char *localPath, HTTPConnection::HTTPMessage &msg)
 static creation function for this object.
static void mount (const char *requestPath, const char *localPath)
 static function to register a new file system type with a logical root path

Static Public Attributes

static std::map< const char
*, const char * > 
m_fsMap
 Map to register different file system types and associate them with different root paths.

Detailed Description

class HTTPFsRequestHandler serves requests with file-system objects

Definition at line 34 of file FsHandler.h.


Constructor & Destructor Documentation

HTTPFsRequestHandler ( const char *  rootPath,
const char *  localPath,
HTTPConnection::HTTPMessage Msg 
)

constructor for HTTPFsRequestHandler object and stores the request related data locally.

the request handling will be initiated from within the constructor.

Parameters:
rootPath: The path under which the handler was registered.
localPath: The path which is relative to the registered file system root.
Msg: Message request information that comes with the request.
Tcp: The socket connection for communicating with the client.

Definition at line 23 of file FsHandler.cpp.

~HTTPFsRequestHandler (  ) [virtual]

Destructor.

Definition at line 55 of file FsHandler.cpp.


Member Function Documentation

static HTTPRequestHandler* create ( const char *  rootPath,
const char *  localPath,
HTTPConnection::HTTPMessage msg 
) [static]

static creation function for this object.

Definition at line 55 of file FsHandler.h.

void handleError ( int  errorCode,
HTTPHeaders *  header = NULL 
) [virtual, inherited]

Handler function which will handle errors and return errors correctly.

Parameters:
errorCode: The error code returned by the HTTP Server to represent the error condition.
msg: Request Message information.
tcp: The socket which represents the active connection to the client.

Definition at line 118 of file HTTPRequestHandler.cpp.

int handleGetRequest (  ) [virtual]

Handler function to serve GET requests.

Implements HTTPRequestHandler.

Definition at line 59 of file FsHandler.cpp.

int handlePostRequest (  ) [virtual]

Handler function to serve POST requests.

Implements HTTPRequestHandler.

Definition at line 119 of file FsHandler.cpp.

int handlePutRequest (  ) [virtual]

Handler function to serve PUT requests.

Implements HTTPRequestHandler.

Definition at line 124 of file FsHandler.cpp.

void handleRequest (  ) [virtual, inherited]

Handler function which will be used by the HTTPServer to serve requests.

The default version of this function will dispatch respective handler member functions according to the request type given in the HTTPMessage object. The list of possible functions dispatched is : * handleGetRequest * handlePostRequest * handlePutRequest

Definition at line 84 of file HTTPRequestHandler.cpp.

static void mount ( const char *  requestPath,
const char *  localPath 
) [static]

static function to register a new file system type with a logical root path

Definition at line 75 of file FsHandler.h.

int parseUriArgs ( string  uri,
map< string, string > &  args 
)

Parse a uri string for uri file name and argument:value pairs.

void startResponse ( int  returnCode,
long  nLen,
HTTPHeaders *  header = NULL 
) [inherited]

Function sends the response header which consists of the return code and the headers section the response header also contains the length (in bytes) of the body.

You need to send the body right after calling this function. Please note that you do not need to consider the terminating CR+LF after your last CR+LF. This will be sent automatically once endResponse is called. Also the Length given in nLen does not need to consider this additional chars. It will also be automatically added in startResponse. if you need to change the headers, please do NOT specify the Content-Length Header. This is done automatically be the function.

Definition at line 142 of file HTTPRequestHandler.cpp.


Field Documentation

std::map< const char *, const char * > m_fsMap [static]

Map to register different file system types and associate them with different root paths.

Definition at line 71 of file FsHandler.h.