StaticFileServing.h 995 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef STATICFILESERVING_H
  2. #define STATICFILESERVING_H
  3. #include <QMimeDatabase>
  4. #include "QtHttpRequest.h"
  5. #include "QtHttpReply.h"
  6. #include "CgiHandler.h"
  7. #include <utils/Logger.h>
  8. class StaticFileServing : public QObject
  9. {
  10. Q_OBJECT
  11. public:
  12. explicit StaticFileServing (QObject * parent = nullptr);
  13. ~StaticFileServing() override;
  14. ///
  15. /// @brief Overwrite current base url
  16. ///
  17. void setBaseUrl(const QString& url);
  18. ///
  19. /// @brief Set a new SSDP description, if empty the description will be unset and clients will get a NotFound
  20. /// @param The description
  21. ///
  22. void setSSDPDescription(const QString& desc);
  23. public slots:
  24. void onRequestNeedsReply (QtHttpRequest * request, QtHttpReply * reply);
  25. private:
  26. QString _baseUrl;
  27. QMimeDatabase * _mimeDb;
  28. CgiHandler _cgi;
  29. Logger * _log;
  30. QByteArray _ssdpDescription;
  31. void printErrorToReply (QtHttpReply * reply, QtHttpReply::StatusCode code, QString errorMessage);
  32. };
  33. #endif // STATICFILESERVING_H