Stellarium 0.15.2
|
Delivers static files. More...
#include <staticfilecontroller.h>
Public Member Functions | |
StaticFileController (const StaticFileControllerSettings &settings, QObject *parent=NULL) | |
Constructor. More... | |
void | service (HttpRequest &request, HttpResponse &response) |
Generates the response. More... | |
QString | getDocRoot () const |
Public Member Functions inherited from HttpRequestHandler | |
HttpRequestHandler (QObject *parent=NULL) | |
Constructor. More... | |
virtual | ~HttpRequestHandler () |
Destructor. More... | |
Static Public Member Functions | |
static QByteArray | getContentType (QString fileName, QString encoding) |
Returns the content type of this file. More... | |
Delivers static files.
It is usually called by the applications main request handler when the caller requests a path that is mapped to static files.
The following settings are required in the config file:
path=../docroot encoding=UTF-8 maxAge=60000 cacheTime=60000 cacheSize=1000000 maxCachedFileSize=65536
The path is relative to the directory of the config file. In case of windows, if the settings are in the registry, the path is relative to the current working directory.
The encoding is sent to the web browser in case of text and html files.
The cache improves performance of small files when loaded from a network drive. Large files are not cached. Files are cached as long as possible, when cacheTime=0. The maxAge value (in msec!) controls the remote browsers cache.
Do not instantiate this class in each request, because this would make the file cache useless. Better create one instance during start-up and call it when the application received a related HTTP request.
Definition at line 69 of file staticfilecontroller.h.
StaticFileController::StaticFileController | ( | const StaticFileControllerSettings & | settings, |
QObject * | parent = NULL |
||
) |
Constructor.
|
static |
Returns the content type of this file.
This is currently only determined by file name.
|
virtual |
Generates the response.
Reimplemented from HttpRequestHandler.