stefanfrings::StaticFileController Class Reference

Delivers static files. More...

#include <staticfilecontroller.h>

Inheritance diagram for stefanfrings::StaticFileController:
Collaboration diagram for stefanfrings::StaticFileController:

Public Member Functions

 StaticFileController (const QSettings *settings, QObject *parent=nullptr)
 Constructor. More...
void service (HttpRequest &request, HttpResponse &response)
 Generates the response.
- Public Member Functions inherited from stefanfrings::HttpRequestHandler
 HttpRequestHandler (QObject *parent=nullptr)
 Constructor. More...
virtual ~HttpRequestHandler ()

Detailed Description

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:


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 45 of file staticfilecontroller.h.

Constructor & Destructor Documentation

◆ StaticFileController()

StaticFileController::StaticFileController ( const QSettings *  settings,
QObject *  parent = nullptr 


settingsConfiguration settings, usually stored in an INI file. Must not be 0. Settings are read from the current group, so the caller must have called settings->beginGroup(). Because the group must not change during runtime, it is recommended to provide a separate QSettings instance that is not used by other parts of the program. The StaticFileController does not take over ownership of the QSettings instance, so the caller should destroy it during shutdown.
parentParent object

Definition at line 13 of file staticfilecontroller.cpp.

The documentation for this class was generated from the following files: