QtWebApp
staticfilecontroller.h
Go to the documentation of this file.
1 
6 #ifndef STATICFILECONTROLLER_H
7 #define STATICFILECONTROLLER_H
8 
9 #include <QCache>
10 #include <QMutex>
11 #include "httpglobal.h"
12 #include "httprequest.h"
13 #include "httpresponse.h"
14 #include "httprequesthandler.h"
15 
16 namespace stefanfrings {
17 
45 class DECLSPEC StaticFileController : public HttpRequestHandler {
46  Q_OBJECT
47  Q_DISABLE_COPY(StaticFileController)
48 public:
49 
60  StaticFileController(const QSettings* settings, QObject* parent = nullptr);
61 
63  void service(HttpRequest& request, HttpResponse& response);
64 
65 private:
66 
68  QString encoding;
69 
71  QString docroot;
72 
74  int maxAge;
75 
76  struct CacheEntry {
77  QByteArray document;
78  qint64 created;
79  QByteArray filename;
80  };
81 
83  int cacheTimeout;
84 
86  int maxCachedFileSize;
87 
89  QCache<QString,CacheEntry> cache;
90 
92  QMutex mutex;
93 
95  void setContentType(const QString file, HttpResponse &response) const;
96 };
97 
98 } // end of namespace
99 
100 #endif // STATICFILECONTROLLER_H
The request handler generates a response for each HTTP request.
This object represents a single HTTP request.
Definition: httprequest.h:37
This object represents a HTTP response, used to return something to the web client.
Definition: httpresponse.h:36