14 #include <QJsonObject> 15 #include <QJsonDocument> 16 #include "httpparser.h" 18 #include "filemanager.h" 19 #include "configuration.h" 20 #include "requestdispatcher.h" 21 #include "cppwebframework_global.h" 27 class CPPWEBFRAMEWORKSHARED_EXPORT
Request 36 QMap<QString, QObject *> attributes;
56 inline void addAttribute(
const std::initializer_list<QPair<QString, QObject *>> &value) noexcept
58 std::for_each(value.begin(), value.end(), [&](
const QPair<QString, QObject *> &v){attributes.insert(v.first, v.second);});
65 inline void addAttribute(
const QString &name, QObject *value) noexcept { attributes.insert(name, value); }
69 inline QMap<QString, QObject *>
getAttributes() const noexcept {
return attributes; }
73 inline const QObject *
getAttribute(
const QString &name)
const noexcept {
return attributes.contains(name) ? attributes[name] :
nullptr; }
77 inline const QByteArray
getBody() const noexcept {
return httpParser->
getBody(); }
85 inline QJsonArray
bodyToJsonArray() const noexcept {
return QJsonDocument::fromJson(httpParser->
getBody()).array(); }
115 inline QByteArray
getRequestURL() const noexcept{
return httpParser !=
nullptr ? httpParser->
getUrl() :
""; }
120 inline QByteArray
getRequestURI() const noexcept {
return httpParser !=
nullptr ? httpParser->
getUrl() :
""; }
147 inline QTcpSocket &
getSocket() const noexcept {
return *socket; }
333 void fillQObject(QObject *
object);
335 void fillQObject(QObject *
object,
const QMap<QByteArray, QByteArray> ¶meters);
QJsonObject bodyToJsonObject() const noexcept
Tries returns the body of the converted request to QJsonObject.
Definition: request.h:81
QTcpSocket & getSocket() const noexcept
This method returns a reference to the current socket.
Definition: request.h:147
void clearAttributes() noexcept
This method will clear all the attributes.
Definition: request.h:100
QJsonArray bodyToJsonArray() const noexcept
Tries returns the body of the converted request to QJsonArray.
Definition: request.h:85
QByteArrayList getParameters(const QByteArray &name) const noexcept
Returns all parameters with a specific name.
Definition: httpparser.h:100
QByteArray getHttpVersion() const noexcept
Returns the HTTP version.
Definition: httpparser.h:65
void setSession(Session &session) noexcept
This method set the user's session.
Definition: request.h:129
The Request class holds all information about a http request.
Definition: request.h:27
void setHttpParser(HttpParser &httpParser) noexcept
This method set the HttpParser.
Definition: request.h:105
QString getPath() const noexcept
This method returns the path.
Definition: request.h:152
The HttpReadRequest class is created automatically by the CppWebServer and inserted in a QThreadPoo...
Definition: httpreadrequest.h:36
The QMapThreadSafety class is a thread safe QMap.
Definition: qmapthreadsafety.h:23
The RequestDispatcher class can be used to dispatch a requisition to a page.
Definition: requestdispatcher.h:20
QByteArray getProtocol() const noexcept
This method returns the http protocol.
Definition: request.h:96
QByteArray getUrl() const noexcept
Returns the url.
Definition: httpparser.h:85
QMultiMap< QByteArray, QByteArray > getUploadedFiles() const noexcept
This method returns all the files that the user has sent.
Definition: request.h:157
QByteArray getRequestURI() const noexcept
This method returns the requested url.
Definition: request.h:120
The Session class holds information about a client session.
Definition: session.h:30
QMap< QString, QObject * > getAttributes() const noexcept
This method returns all the attributes of a HttpReadRequest.
Definition: request.h:69
QString getPath() const noexcept
Returns the path to the server's folder.
Definition: configuration.h:112
The class parses a HTTP message.
Definition: httpparser.h:21
QByteArrayList getParameters(const QByteArray &name) const noexcept
This method returns the parameters from a request given an specific name.
Definition: request.h:142
void addAttribute(const QString &name, QObject *value) noexcept
This method add an attribute that will be passed to a view page. The object can be processed within a...
Definition: request.h:65
QByteArray getBody() const noexcept
Returns HTTP body message.
Definition: httpparser.h:75
All classes of C++ Web Framework are contained within the namespace CWF.
Definition: configuration.h:24
The Response class is responsable to response a Http request.
Definition: response.h:25
QMultiMap< QByteArray, QByteArray > getUploadedFiles() const noexcept
Returns all uploaded files.
Definition: httpparser.h:110
QByteArray getParameter(const QByteArray &name) const noexcept
Returns a specific parameter given a name. If the parameter name does not exists, the function return...
Definition: httpparser.h:94
const QObject * getAttribute(const QString &name) const noexcept
This method returns a specific object given its name.
Definition: request.h:73
void addAttribute(const std::initializer_list< QPair< QString, QObject *>> &value) noexcept
This method add attributes that will be passed to a view page. The object can be processed within a p...
Definition: request.h:56
QByteArray getRequestURL() const noexcept
This method returns the requested url.
Definition: request.h:115
const QByteArray getBody() const noexcept
Returns the request body.
Definition: request.h:77
QByteArray getParameter(const QByteArray &name) const noexcept
This method returns the most recent parameter from a request given an specific name.
Definition: request.h:136
HttpParser & getHttpParser() const noexcept
This method returns the HttpParser.
Definition: request.h:110