Barracuda Application Server C/C++ Reference
HttpResMgr Struct Reference

The HttpResMgr class makes it possible for HTTP clients to use an IoIntf for uploading and downloading files. More...

#include <HttpResMgr.h>

Inheritance diagram for HttpResMgr:

Public Member Functions

 HttpResMgr (IoIntf *io, int maxUploads, const char *dirName, AllocatorIntf *alloc=0, S8 priority=0)
 Initializes a HttpResMgr. More...
 ~HttpResMgr ()
 Terminate the HttpResMgr object. More...
- Public Member Functions inherited from HttpDir
 HttpDir ()
 Constructor for creating a root dir, a root dir has no name.
 HttpDir (const char *name, S8 priority=0)
 Constructor for creating a sub-directory. More...
int insertDir (HttpDir *dir)
 Insert a sub-directory. More...
int insertPage (HttpPage *page)
 Insert a page in the directory. More...
HttpPagegetFirstPage ()
 Returns the first page.
HttpDirgetFirstDir ()
 Returns the first sub-directory.
HttpDirgetDir (const char *name)
 Returns the first directory with the name given or NULL if not found.
HttpPagegetPage (const char *name)
 Returns the page with the name given or NULL if not found.
HttpDirgetNext ()
 Returns the next dir in the parent list. More...
HttpPagefindPage (HttpPage *iter, const char *name)
 Searches for a page in this directory node. More...
HttpDircreateOrGet (const char *name)
 Returns a sub-directory with the given name. More...
const char * getName () const
 Returns the directory name.
HttpDirgetParent () const
 Returns the parent directory or NULL if no parent.
char * makeAbsPath (const char *relPath, int relPathLen)
 Makes an absolute path based on where the HttpDir instance is installed in the virtual file system and the provided relative path. More...
char * getRootPath ()
 Calculates the root of where the HttpDir instance is installed in the virtual file system. More...
HttpDir_Service overloadService (HttpDir_Service s)
 Replace the original service function in HttpDir with your own. More...
void p403 (const char *p403)
 Set a 403 denied request handler. More...
bool isLinked ()
 Returns true if this directory node is installed into a parent directory.
int unlink ()
 Unlinks/removes the directory from the parent directory.
void setAuthenticator (struct AuthenticatorIntf *authenticator, struct AuthorizerIntf *authorizer=0)
 Set the optional authenticator and/or the optional AuthorizerIntf. More...
bool authenticateAndAuthorize (HttpCommand *cmd, const char *path)
 Authenticate and authorize the user. More...

Additional Inherited Members

- Static Public Member Functions inherited from HttpDir
static HttpDirfindDir (HttpDir *iter, const char *name, unsigned int nameLen)
 Searches for a sub-directory in this directory node. More...

Detailed Description

The HttpResMgr class makes it possible for HTTP clients to use an IoIntf for uploading and downloading files.

The HttpResMgr is similar in functionality to an FTP server, but uses HTTP for the transport of data.

The HttpResMgr is implemented in C code, but we also provide a Web File Manager implemented in Lua code. See the WFS documentation for more information on the Lua version.

The HttpResMgr is designed to be used from both browser clients and non-browser clients. The HttpResMgr detects the difference between a browser and non-browser client by looking at the commands sent to the HttpResMgr resource and the upload type.

The HttpResMgr can also work with "read only" IoIntf implementations such as the ZipIo, but any "write" command type is denied.

Unlike the HttpResRdr class, the HttpResMgr does not do any translations on downloaded files. The HttpResMgr should be used for file transfer and not for serving general HTML files, images, etc, to a client. A request for a directory returns a list of all resources in the directory. This is different from the HttpResRdr class, which attempts to locate the index.html file for directory requests.

For security reasons, a HttpResMgr should not be used without an authenticator.

The HttpResMgr is an example application for how to make a class that inherits from HttpDir. The HttpResMgr class can be considered a resource collection. The HttpResMgr source code and example can be found in the example/HttpResMgr directory.

Constructor & Destructor Documentation

◆ HttpResMgr()

HttpResMgr::HttpResMgr ( IoIntf io,
int  maxUploads,
const char *  dirName,
AllocatorIntf alloc = 0,
S8  priority = 0 

Initializes a HttpResMgr.

iois a IoIntf implementation such as DiskIo
maxUploadsis the limit value for concurrent uploads. The maximum numbers of downloads are controlled by the HttpCmdThreadPool. See the limitations section in HttpResRdr for more information on how the download works.
dirNameis the HttpDir name.
allocis the allocator used when allocating "concurrent upload" objects.
priorityis the HttpDir priority

◆ ~HttpResMgr()

HttpResMgr::~HttpResMgr ( )

Terminate the HttpResMgr object.

Please note that any upload in progress will be aborted.