2016-06-12 22:27:24 +02:00
|
|
|
#ifndef STATICFILESERVING_H
|
|
|
|
#define STATICFILESERVING_H
|
|
|
|
|
2018-12-28 18:12:45 +01:00
|
|
|
#include <QMimeDatabase>
|
2018-12-30 22:07:53 +01:00
|
|
|
|
|
|
|
//#include "QtHttpServer.h"
|
2016-06-12 22:27:24 +02:00
|
|
|
#include "QtHttpRequest.h"
|
|
|
|
#include "QtHttpReply.h"
|
|
|
|
#include "QtHttpHeader.h"
|
2018-12-30 22:07:53 +01:00
|
|
|
#include "CgiHandler.h"
|
2016-06-14 20:14:06 +02:00
|
|
|
|
2016-07-12 13:47:30 +02:00
|
|
|
#include <utils/Logger.h>
|
2016-06-12 22:27:24 +02:00
|
|
|
|
|
|
|
class StaticFileServing : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-12-28 18:12:45 +01:00
|
|
|
explicit StaticFileServing (QObject * parent = nullptr);
|
2016-06-12 22:27:24 +02:00
|
|
|
virtual ~StaticFileServing (void);
|
|
|
|
|
2018-12-30 22:07:53 +01:00
|
|
|
///
|
|
|
|
/// @brief Overwrite current base url
|
|
|
|
///
|
2018-12-27 23:11:32 +01:00
|
|
|
void setBaseUrl(const QString& url);
|
2018-12-30 22:07:53 +01:00
|
|
|
///
|
|
|
|
/// @brief Set a new SSDP description, if empty the description will be unset and clients will get a NotFound
|
|
|
|
/// @param The description
|
|
|
|
///
|
|
|
|
void setSSDPDescription(const QString& desc);
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2016-06-12 22:27:24 +02:00
|
|
|
public slots:
|
|
|
|
void onRequestNeedsReply (QtHttpRequest * request, QtHttpReply * reply);
|
|
|
|
|
|
|
|
private:
|
2016-06-14 20:14:06 +02:00
|
|
|
QString _baseUrl;
|
|
|
|
QMimeDatabase * _mimeDb;
|
|
|
|
CgiHandler _cgi;
|
2016-09-03 15:54:33 +02:00
|
|
|
Logger * _log;
|
2018-12-30 22:07:53 +01:00
|
|
|
QByteArray _ssdpDescription;
|
2016-07-12 13:47:30 +02:00
|
|
|
|
2017-01-29 21:20:12 +01:00
|
|
|
void printErrorToReply (QtHttpReply * reply, QtHttpReply::StatusCode code, QString errorMessage);
|
|
|
|
|
2016-06-12 22:27:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // STATICFILESERVING_H
|