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