14 #include <QNetworkCookie> 15 #include "cppwebframework_global.h" 24 qint64 contentLenght = 0;
25 QByteArray contentType;
26 QByteArray httpVersion;
31 QMultiMap<QByteArray, QByteArray> parameters;
32 QMultiMap<QByteArray, QByteArray> headerField;
33 QMultiMap<QByteArray, QByteArray> files;
34 QVector<QNetworkCookie> cookies;
36 bool multiPart =
false;
37 bool readFile =
false;
38 bool extractHeaderAndBody(QByteArray &httpMessage);
39 void doParse(QByteArray &httpMessage);
40 void doParseHttpHeader(QByteArray &httpMessage);
44 void extractCookies();
50 explicit HttpParser(QByteArray &httpMessage) { doParse(httpMessage); }
70 inline QByteArray
getMethod() const noexcept {
return method; }
75 inline QByteArray
getBody() const noexcept {
return body; }
80 inline QByteArray
getSessionId() const noexcept {
return sessionId; }
85 inline QByteArray
getUrl() const noexcept {
return url; }
94 inline QByteArray
getParameter(
const QByteArray &name)
const noexcept {
return parameters.value(name); }
100 inline QByteArrayList
getParameters(
const QByteArray &name)
const noexcept {
return parameters.values(name); }
105 inline QMultiMap<QByteArray, QByteArray>
getParameters() const noexcept {
return parameters; }
110 inline QMultiMap<QByteArray, QByteArray>
getUploadedFiles() const noexcept {
return files; }
115 inline QVector<QNetworkCookie>
getCookies() const noexcept {
return cookies; }
121 inline QByteArrayList
getHeaderFields(
const QByteArray &name)
const noexcept {
return headerField.values(name); }
130 inline QByteArray
getHeaderField(
const QByteArray &name)
const noexcept {
return headerField.value(name); }
135 inline bool isValid() const noexcept {
return valid; }
150 #endif // HTTPPARSER_H HttpParser(QByteArray &httpMessage)
This constructor receives a HTTP message and parses it.
Definition: httpparser.h:50
QByteArray getHeaderField(const QByteArray &name) const noexcept
Returns a specific header field given a name. If the header field name does not exists, the function returns defaultValue. If no defaultValue is specified, the function returns a default-constructed value. If there are multiple header field with a name, the value of the most recently inserted one is returned.
Definition: httpparser.h:130
QByteArray getSessionId() const noexcept
Returns session id.
Definition: httpparser.h:80
qint64 getContentLenght() const noexcept
Returns the content lenght.
Definition: httpparser.h:55
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
QByteArray getMethod() const noexcept
Returns HTTP method.
Definition: httpparser.h:70
QByteArrayList getHeaderFields(const QByteArray &name) const noexcept
Returns all header fields given a specific name.
Definition: httpparser.h:121
QByteArray getContentType() const noexcept
Returns the content type.
Definition: httpparser.h:60
The HttpReadRequest class is created automatically by the CppWebServer and inserted in a QThreadPoo...
Definition: httpreadrequest.h:36
bool getReadFile() const noexcept
Returns true if all message was read.
Definition: httpparser.h:145
QMultiMap< QByteArray, QByteArray > getParameters() const noexcept
Returns all parameters.
Definition: httpparser.h:105
bool isValid() const noexcept
Returns true if HTTP is valid, else it returns false.
Definition: httpparser.h:135
QByteArray getUrl() const noexcept
Returns the url.
Definition: httpparser.h:85
bool isMultiPart() const noexcept
Returns the multi part.
Definition: httpparser.h:140
QVector< QNetworkCookie > getCookies() const noexcept
Returns all cookies.
Definition: httpparser.h:115
The class parses a HTTP message.
Definition: httpparser.h:21
QByteArray getBody() const noexcept
Returns HTTP body message.
Definition: httpparser.h:75
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