diff --git a/src/webui/httpconnection.cpp b/src/webui/httpconnection.cpp index 1b3514341..7d15a856e 100644 --- a/src/webui/httpconnection.cpp +++ b/src/webui/httpconnection.cpp @@ -220,7 +220,7 @@ void HttpConnection::respond() { qDebug("Returning favicon"); QFile favicon(":/Icons/skin/qbittorrent16.png"); if (favicon.open(QIODevice::ReadOnly)) { - QByteArray data = favicon.readAll(); + const QByteArray data = favicon.readAll(); favicon.close(); m_generator.setStatusLine(200, "OK"); m_generator.setContentTypeByExt("png"); @@ -474,9 +474,9 @@ void HttpConnection::respondCommand(const QString& command) { m_generator.setStatusLine(200, "OK"); m_generator.setContentTypeByExt("html"); #if LIBTORRENT_VERSION_MINOR > 15 - m_generator.setMessage(QString::number(QBtSession::instance()->getSession()->settings().upload_rate_limit)); + m_generator.setMessage(QByteArray::number(QBtSession::instance()->getSession()->settings().upload_rate_limit)); #else - m_generator.setMessage(QString::number(QBtSession::instance()->getSession()->upload_rate_limit())); + m_generator.setMessage(QByteArray::number(QBtSession::instance()->getSession()->upload_rate_limit())); #endif write(); return; @@ -485,9 +485,9 @@ void HttpConnection::respondCommand(const QString& command) { m_generator.setStatusLine(200, "OK"); m_generator.setContentTypeByExt("html"); #if LIBTORRENT_VERSION_MINOR > 15 - m_generator.setMessage(QString::number(QBtSession::instance()->getSession()->settings().download_rate_limit)); + m_generator.setMessage(QByteArray::number(QBtSession::instance()->getSession()->settings().download_rate_limit)); #else - m_generator.setMessage(QString::number(QBtSession::instance()->getSession()->download_rate_limit())); + m_generator.setMessage(QByteArray::number(QBtSession::instance()->getSession()->download_rate_limit())); #endif write(); return; @@ -498,7 +498,7 @@ void HttpConnection::respondCommand(const QString& command) { if (h.is_valid()) { m_generator.setStatusLine(200, "OK"); m_generator.setContentTypeByExt("html"); - m_generator.setMessage(QString::number(h.upload_limit())); + m_generator.setMessage(QByteArray::number(h.upload_limit())); write(); } return; @@ -509,7 +509,7 @@ void HttpConnection::respondCommand(const QString& command) { if (h.is_valid()) { m_generator.setStatusLine(200, "OK"); m_generator.setContentTypeByExt("html"); - m_generator.setMessage(QString::number(h.download_limit())); + m_generator.setMessage(QByteArray::number(h.download_limit())); write(); } return; diff --git a/src/webui/httprequestparser.cpp b/src/webui/httprequestparser.cpp index f0ba21598..77881c46e 100644 --- a/src/webui/httprequestparser.cpp +++ b/src/webui/httprequestparser.cpp @@ -45,11 +45,11 @@ bool HttpRequestParser::isError() const { return m_error; } -QString HttpRequestParser::url() const { +const QString& HttpRequestParser::url() const { return m_path; } -QByteArray HttpRequestParser::message() const { +const QByteArray& HttpRequestParser::message() const { return m_data; } diff --git a/src/webui/httprequestparser.h b/src/webui/httprequestparser.h index 39f9be1e9..999aeefa6 100644 --- a/src/webui/httprequestparser.h +++ b/src/webui/httprequestparser.h @@ -32,7 +32,8 @@ #ifndef HTTPREQUESTPARSER_H #define HTTPREQUESTPARSER_H -#include +#include +#include class HttpRequestParser { @@ -40,22 +41,22 @@ public: HttpRequestParser(); ~HttpRequestParser(); bool isError() const; - QString url() const; - QByteArray message() const; + const QString& url() const; + const QByteArray& message() const; QString get(const QString& key) const; QString post(const QString& key) const; const QByteArray& torrent() const; void writeHeader(const QByteArray& ba); void writeMessage(const QByteArray& ba); - inline QHttpRequestHeader& header() { return m_header; } + inline const QHttpRequestHeader& header() const { return m_header; } private: QHttpRequestHeader m_header; bool m_error; QByteArray m_data; QString m_path; - QMap m_postMap; - QMap m_getMap; + QHash m_postMap; + QHash m_getMap; QByteArray m_torrentContent; }; diff --git a/src/webui/httpresponsegenerator.cpp b/src/webui/httpresponsegenerator.cpp index 37c4840b7..7f7ac267f 100644 --- a/src/webui/httpresponsegenerator.cpp +++ b/src/webui/httpresponsegenerator.cpp @@ -33,11 +33,12 @@ void HttpResponseGenerator::setMessage(const QByteArray& message) { - HttpResponseGenerator::message = message; - setContentLength(message.size()); + m_message = message; + setContentLength(message.size()); } -void HttpResponseGenerator::setMessage(const QString& message) { +void HttpResponseGenerator::setMessage(const QString& message) +{ setMessage(message.toUtf8()); } diff --git a/src/webui/httpresponsegenerator.h b/src/webui/httpresponsegenerator.h index e86cfa7dc..ef71cf645 100644 --- a/src/webui/httpresponsegenerator.h +++ b/src/webui/httpresponsegenerator.h @@ -42,11 +42,11 @@ class HttpResponseGenerator : public QHttpResponseHeader void setMessage(const QString& message); void setContentTypeByExt(const QString& ext); inline QByteArray toByteArray() const { - return QHttpResponseHeader::toString().toUtf8() + message; + return QHttpResponseHeader::toString().toUtf8() + m_message; } private: - QByteArray message; + QByteArray m_message; };