|
|
|
@ -31,6 +31,9 @@
@@ -31,6 +31,9 @@
|
|
|
|
|
|
|
|
|
|
#include "httprequestparser.h" |
|
|
|
|
#include <QUrl> |
|
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) |
|
|
|
|
#include <QUrlQuery> |
|
|
|
|
#endif |
|
|
|
|
#include <QDebug> |
|
|
|
|
|
|
|
|
|
HttpRequestParser::HttpRequestParser(): m_error(false) |
|
|
|
@ -69,11 +72,16 @@ void HttpRequestParser::writeHeader(const QByteArray& ba) {
@@ -69,11 +72,16 @@ void HttpRequestParser::writeHeader(const QByteArray& ba) {
|
|
|
|
|
m_error = false; |
|
|
|
|
// Parse header
|
|
|
|
|
m_header = QHttpRequestHeader(ba); |
|
|
|
|
QUrl url = QUrl::fromEncoded(m_header.path().toAscii()); |
|
|
|
|
QUrl url = QUrl::fromEncoded(m_header.path().toLatin1()); |
|
|
|
|
m_path = url.path(); |
|
|
|
|
|
|
|
|
|
// Parse GET parameters
|
|
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) |
|
|
|
|
QUrlQuery query(url); |
|
|
|
|
QListIterator<QPair<QString, QString> > i(query.queryItems()); |
|
|
|
|
#else |
|
|
|
|
QListIterator<QPair<QString, QString> > i(url.queryItems()); |
|
|
|
|
#endif |
|
|
|
|
while (i.hasNext()) { |
|
|
|
|
QPair<QString, QString> pair = i.next(); |
|
|
|
|
m_getMap[pair.first] = pair.second; |
|
|
|
@ -102,8 +110,14 @@ void HttpRequestParser::writeMessage(const QByteArray& ba) {
@@ -102,8 +110,14 @@ void HttpRequestParser::writeMessage(const QByteArray& ba) {
|
|
|
|
|
// Parse POST data
|
|
|
|
|
if (m_header.contentType() == "application/x-www-form-urlencoded") { |
|
|
|
|
QUrl url; |
|
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) |
|
|
|
|
QString tmp(m_data); |
|
|
|
|
QUrlQuery query(tmp); |
|
|
|
|
QListIterator<QPair<QString, QString> > i(query.queryItems()); |
|
|
|
|
#else |
|
|
|
|
url.setEncodedQuery(m_data); |
|
|
|
|
QListIterator<QPair<QString, QString> > i(url.queryItems()); |
|
|
|
|
#endif |
|
|
|
|
while (i.hasNext()) { |
|
|
|
|
QPair<QString, QString> pair = i.next(); |
|
|
|
|
m_postMap[pair.first] = pair.second; |
|
|
|
|