8 #ifndef _HttpRequest_H_ 9 #define _HttpRequest_H_ 11 #include <QTemporaryFile> 50 QHostAddress
peerAddress()
const {
return m_connection->peerAddress(); }
73 QString
method()
const {
return m_method; }
88 QString
version()
const {
return m_version; }
93 QString
header(
const QString& name)
const;
100 QList<QString>
headers(
const QString& name)
const;
107 QMultiMap<QString, QString>
headerMap()
const {
return m_headers; }
116 QString
parameter(
const QString& name)
const {
return m_parameters.value(name); }
121 QList<QString>
parameters(
const QString& name)
const {
return m_parameters.values(name); }
126 QMultiMap<QString, QString>
parameterMap()
const {
return m_parameters; }
133 QByteArray
body()
const {
return m_bodyData; }
138 static QString
urlDecode(
const QString& source);
143 QString
cookie(
const QString& name)
const {
return m_cookies.value(name); }
148 const QMap<QString, QString>&
cookieMap() {
return m_cookies; }
156 QTemporaryFile *
uploadedFile(
const QString& fieldName) {
return m_uploadedFiles.value(fieldName); }
168 const QMap<QString, QTemporaryFile *>&
uploadedFiles()
const {
return m_uploadedFiles; }
178 const QMap<QString, QString>&
contentTypes()
const {
return m_contentTypes; }
184 QString
contentType(
const QString& fieldName)
const {
return m_contentTypes.value(fieldName); }
190 const QDateTime&
datetime()
const {
return m_datetime; }
194 #ifndef DOXYGEN_SHOULD_SKIP_THIS 195 QMultiMap<QString, QString> m_headers;
196 QMultiMap<QString, QString> m_parameters;
197 QMap<QString, QTemporaryFile *> m_uploadedFiles;
198 QMap<QString, QString> m_contentTypes;
199 QMap<QString, QString> m_cookies;
200 QByteArray m_bodyData;
206 QByteArray m_boundary;
208 int m_expectedBodySize;
209 QString m_currentHeader;
210 QTemporaryFile m_tempFile;
212 QDateTime m_datetime;
QList< QString > parameters(const QString &name) const
Returns all parameters of the HTTP request in QList.
QString statusString() const
Returns current status of the request as a string.
QList< QString > headers(const QString &name) const
Returns all headers of HTTP request in QList, case insensitive.
QString fullPath() const
Returns full path of the request (/files/index.html) including parameters.
QString path() const
Returns path of the request (/files/index.html)
const QMap< QString, QString > & cookieMap()
Returns all cookies of the request in QMap.
Status
Inner state of request, changes when parts of request are read from networkd.
void readHeader(QTcpSocket *socket)
Reads HTTP headers of the request.
void parseMultiPartFile()
Parses the mime multipart request.
Status status() const
Returns current status of the request.
QHostAddress peerAddress() const
Returns peer's host address.
QString contentType(const QString &fieldName) const
Returns content type of uploaded file.
QString version() const
Returns version of HTTP protocol (HTTP/1.1)
QTemporaryFile * uploadedFile(const QString &fieldName)
Returns temporary file with uploaded file from html form.
HttpConnection * connection() const
Returns HttpConnection of the request.
QMultiMap< QString, QString > parameterMap() const
Returns all parameters of the HTTP request in QMap.
QString cookie(const QString &name) const
Returns cookie.
const QMap< QString, QTemporaryFile * > & uploadedFiles() const
Returns list of uploaded files.
QString header(const QString &name) const
Returns requested header value, case insensitive.
static QString urlDecode(const QString &source)
Converts URL encoded string to UTF8 string.
void readBody(QTcpSocket *socket)
Reads body of the request.
QMultiMap< QString, QString > headerMap() const
Returns all headers of HTTP request in QMap.
const QMap< QString, QString > & contentTypes() const
Returns list of content types of uploaded files.
const QDateTime & datetime() const
Returns date and time of the request.
QByteArray body() const
Returns the body of the request.
QString parameter(const QString &name) const
Returns parameter of the HTTP request.
Processes HTTP request, parses headers, body and files sent by HTTP protocol.
void readFromSocket(QTcpSocket *socket)
Reads data from socket.
void readRequest(QTcpSocket *socket)
Reads request from socket.
void extractCookies()
Parses cookies.
QString method() const
Returns used HTTP method of the request (GET, PUT, POST or DELETE)
Namespace of HTTP server.
HttpRequest(HttpConnection *connection)
Constructor sets default falues from configuration.
One single connection to http server.
void decodeRequestParams()
Parses parameters of the URL.