| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- /*
- Copyright 2017 Herik Lima de Castro and Marcelo Medeiros Eler
- Distributed under MIT license, or public domain if desired and
- recognized in your jurisdiction.
- See file LICENSE for detail.
- */
- #ifndef HTTPREADREQUEST_H
- #define HTTPREADREQUEST_H
- #include <QFile>
- #include <QMap>
- #include <QRunnable>
- #include <QSslConfiguration>
- #include <QStringList>
- #include <QTcpSocket>
- #include "httpparser.h"
- #include "request.h"
- #include "response.h"
- #include "cppwebframework_global.h"
- #include "qmapthreadsafety.h"
- CWF_BEGIN_NAMESPACE
- class Configuration;
- class Controller;
- class Session;
- class Filter;
- /**
- * @brief The HttpReadRequest class is created automatically by the CppWebServer and inserted <br>
- * in a QThreadPool, always when the CppWebServer has a call by a client(Browser).
- */
- class CPPWEBFRAMEWORKSHARED_EXPORT HttpReadRequest : public QRunnable
- {
- qintptr socketDescriptor;
- QMapThreadSafety<QString, Controller *> &urlController;
- QMapThreadSafety<QString, Session *> &sessions;
- const Configuration &configuration;
- QSslConfiguration *ssl;
- Filter *filter;
- QTcpSocket *socket = nullptr;
- qint64 maxUploadFile{};
- bool readBody(HttpParser &parser, Request &request, Response &response);
- bool buildSslSocket();
- void buildSocket();
- public:
- /**
- * @brief This constructor provides the necessary information to create a HttpReadRequest
- * @param qintptr socketDescriptor : Used to create a socket.
- * @param QMapThreadSafety<QString, Controller *> &urlController : All mapped controllers
- * @param QMapThreadSafety<QString, Session *> &sessions : Sessions.
- * @param QSslConfiguration *sslConfiguration : SSL configuration.
- * @param Filter *filter : Filter
- */
- HttpReadRequest(qintptr socketDescriptor,
- QMapThreadSafety<QString, Controller *> &urlController,
- QMapThreadSafety<QString, Session *> &sessions,
- const Configuration &configuration,
- QSslConfiguration *ssl,
- Filter *filter);
- /**
- * @brief Destroys dynamically allocated resources.
- */
- ~HttpReadRequest() override;
- /**
- * @brief Starts to read the requisition.
- */
- void run() override;
- };
- CWF_END_NAMESPACE
- #endif // HTTPREADREQUEST_H
|