mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 23:07:59 +00:00
Web UI code optimization and clean up
This commit is contained in:
parent
ab0355f8d6
commit
4385b941bb
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include <QHttpRequestHeader>
|
#include <QHttpRequestHeader>
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
#include <libtorrent/bencode.hpp>
|
#include <libtorrent/bencode.hpp>
|
||||||
#include <libtorrent/entry.hpp>
|
#include <libtorrent/entry.hpp>
|
||||||
@ -86,27 +87,36 @@ void QTracker::readRequest()
|
|||||||
QTcpSocket *socket = static_cast<QTcpSocket*>(sender());
|
QTcpSocket *socket = static_cast<QTcpSocket*>(sender());
|
||||||
QByteArray input = socket->readAll();
|
QByteArray input = socket->readAll();
|
||||||
//qDebug("QTracker: Raw request:\n%s", input.data());
|
//qDebug("QTracker: Raw request:\n%s", input.data());
|
||||||
HttpRequestParser parser;
|
QHttpRequestHeader http_request(input);
|
||||||
parser.write(input);
|
if(!http_request.isValid()) {
|
||||||
if(!parser.isValid()) {
|
qDebug("QTracker: Invalid HTTP Request:\n %s", qPrintable(http_request.toString()));
|
||||||
qDebug("QTracker: Invalid HTTP Request:\n %s", qPrintable(parser.toString()));
|
|
||||||
respondInvalidRequest(socket, 100, "Invalid request type");
|
respondInvalidRequest(socket, 100, "Invalid request type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//qDebug("QTracker received the following request:\n%s", qPrintable(parser.toString()));
|
//qDebug("QTracker received the following request:\n%s", qPrintable(parser.toString()));
|
||||||
// Request is correct, is it a GET request?
|
// Request is correct, is it a GET request?
|
||||||
if(parser.method() != "GET") {
|
if(http_request.method() != "GET") {
|
||||||
qDebug("QTracker: Unsupported HTTP request: %s", qPrintable(parser.method()));
|
qDebug("QTracker: Unsupported HTTP request: %s", qPrintable(http_request.method()));
|
||||||
respondInvalidRequest(socket, 100, "Invalid request type");
|
respondInvalidRequest(socket, 100, "Invalid request type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!parser.url().startsWith("/announce", Qt::CaseInsensitive)) {
|
if(!http_request.path().startsWith("/announce", Qt::CaseInsensitive)) {
|
||||||
qDebug("QTracker: Unrecognized path: %s", qPrintable(parser.url()));
|
qDebug("QTracker: Unrecognized path: %s", qPrintable(http_request.path()));
|
||||||
respondInvalidRequest(socket, 100, "Invalid request type");
|
respondInvalidRequest(socket, 100, "Invalid request type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// OK, this is a GET request
|
// OK, this is a GET request
|
||||||
respondToAnnounceRequest(socket, parser);
|
// Parse GET parameters
|
||||||
|
QHash<QString, QString> get_parameters;
|
||||||
|
QUrl url = QUrl::fromEncoded(http_request.path().toAscii());
|
||||||
|
QListIterator<QPair<QString, QString> > i(url.queryItems());
|
||||||
|
while (i.hasNext()) {
|
||||||
|
QPair<QString, QString> pair = i.next();
|
||||||
|
get_parameters[pair.first] = pair.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
respondToAnnounceRequest(socket, get_parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTracker::respondInvalidRequest(QTcpSocket *socket, int code, QString msg)
|
void QTracker::respondInvalidRequest(QTcpSocket *socket, int code, QString msg)
|
||||||
@ -117,18 +127,19 @@ void QTracker::respondInvalidRequest(QTcpSocket *socket, int code, QString msg)
|
|||||||
socket->disconnectFromHost();
|
socket->disconnectFromHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTracker::respondToAnnounceRequest(QTcpSocket *socket, const HttpRequestParser& parser)
|
void QTracker::respondToAnnounceRequest(QTcpSocket *socket,
|
||||||
|
const QHash<QString, QString>& get_parameters)
|
||||||
{
|
{
|
||||||
TrackerAnnounceRequest annonce_req;
|
TrackerAnnounceRequest annonce_req;
|
||||||
// IP
|
// IP
|
||||||
annonce_req.peer.ip = socket->peerAddress().toString();
|
annonce_req.peer.ip = socket->peerAddress().toString();
|
||||||
// 1. Get info_hash
|
// 1. Get info_hash
|
||||||
if(parser.get("info_hash").isNull()) {
|
if(!get_parameters.contains("info_hash")) {
|
||||||
qDebug("QTracker: Missing info_hash");
|
qDebug("QTracker: Missing info_hash");
|
||||||
respondInvalidRequest(socket, 101, "Missing info_hash");
|
respondInvalidRequest(socket, 101, "Missing info_hash");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
annonce_req.info_hash = parser.get("info_hash");
|
annonce_req.info_hash = get_parameters.value("info_hash");
|
||||||
// info_hash cannot be longer than 20 bytes
|
// info_hash cannot be longer than 20 bytes
|
||||||
/*if(annonce_req.info_hash.toAscii().length() > 20) {
|
/*if(annonce_req.info_hash.toAscii().length() > 20) {
|
||||||
qDebug("QTracker: Info_hash is not 20 byte long: %s (%d)", qPrintable(annonce_req.info_hash), annonce_req.info_hash.toAscii().length());
|
qDebug("QTracker: Info_hash is not 20 byte long: %s (%d)", qPrintable(annonce_req.info_hash), annonce_req.info_hash.toAscii().length());
|
||||||
@ -136,12 +147,12 @@ void QTracker::respondToAnnounceRequest(QTcpSocket *socket, const HttpRequestPar
|
|||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
// 2. Get peer ID
|
// 2. Get peer ID
|
||||||
if(parser.get("peer_id").isNull()) {
|
if(!get_parameters.contains("peer_id")) {
|
||||||
qDebug("QTracker: Missing peer_id");
|
qDebug("QTracker: Missing peer_id");
|
||||||
respondInvalidRequest(socket, 102, "Missing peer_id");
|
respondInvalidRequest(socket, 102, "Missing peer_id");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
annonce_req.peer.peer_id = parser.get("peer_id");
|
annonce_req.peer.peer_id = get_parameters.value("peer_id");
|
||||||
// peer_id cannot be longer than 20 bytes
|
// peer_id cannot be longer than 20 bytes
|
||||||
/*if(annonce_req.peer.peer_id.length() > 20) {
|
/*if(annonce_req.peer.peer_id.length() > 20) {
|
||||||
qDebug("QTracker: peer_id is not 20 byte long: %s", qPrintable(annonce_req.peer.peer_id));
|
qDebug("QTracker: peer_id is not 20 byte long: %s", qPrintable(annonce_req.peer.peer_id));
|
||||||
@ -149,13 +160,13 @@ void QTracker::respondToAnnounceRequest(QTcpSocket *socket, const HttpRequestPar
|
|||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
// 3. Get port
|
// 3. Get port
|
||||||
if(parser.get("port").isNull()) {
|
if(!get_parameters.contains("port")) {
|
||||||
qDebug("QTracker: Missing port");
|
qDebug("QTracker: Missing port");
|
||||||
respondInvalidRequest(socket, 103, "Missing port");
|
respondInvalidRequest(socket, 103, "Missing port");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
annonce_req.peer.port = parser.get("port").toInt(&ok);
|
annonce_req.peer.port = get_parameters.value("port").toInt(&ok);
|
||||||
if(!ok || annonce_req.peer.port < 1 || annonce_req.peer.port > 65535) {
|
if(!ok || annonce_req.peer.port < 1 || annonce_req.peer.port > 65535) {
|
||||||
qDebug("QTracker: Invalid port number (%d)", annonce_req.peer.port);
|
qDebug("QTracker: Invalid port number (%d)", annonce_req.peer.port);
|
||||||
respondInvalidRequest(socket, 103, "Missing port");
|
respondInvalidRequest(socket, 103, "Missing port");
|
||||||
@ -163,14 +174,14 @@ void QTracker::respondToAnnounceRequest(QTcpSocket *socket, const HttpRequestPar
|
|||||||
}
|
}
|
||||||
// 4. Get event
|
// 4. Get event
|
||||||
annonce_req.event = "";
|
annonce_req.event = "";
|
||||||
if(!parser.get("event").isNull()) {
|
if(get_parameters.contains("event")) {
|
||||||
annonce_req.event = parser.get("event");
|
annonce_req.event = get_parameters.value("event");
|
||||||
qDebug("QTracker: event is %s", qPrintable(annonce_req.event));
|
qDebug("QTracker: event is %s", qPrintable(annonce_req.event));
|
||||||
}
|
}
|
||||||
// 5. Get numwant
|
// 5. Get numwant
|
||||||
annonce_req.numwant = 50;
|
annonce_req.numwant = 50;
|
||||||
if(!parser.get("numwant").isNull()) {
|
if(get_parameters.contains("numwant")) {
|
||||||
int tmp = parser.get("numwant").toInt();
|
int tmp = get_parameters.value("numwant").toInt();
|
||||||
if(tmp > 0) {
|
if(tmp > 0) {
|
||||||
qDebug("QTracker: numwant=%d", tmp);
|
qDebug("QTracker: numwant=%d", tmp);
|
||||||
annonce_req.numwant = tmp;
|
annonce_req.numwant = tmp;
|
||||||
@ -178,7 +189,7 @@ void QTracker::respondToAnnounceRequest(QTcpSocket *socket, const HttpRequestPar
|
|||||||
}
|
}
|
||||||
// 6. no_peer_id (extension)
|
// 6. no_peer_id (extension)
|
||||||
annonce_req.no_peer_id = false;
|
annonce_req.no_peer_id = false;
|
||||||
if(parser.hasKey("no_peer_id")) {
|
if(get_parameters.contains("no_peer_id")) {
|
||||||
annonce_req.no_peer_id = true;
|
annonce_req.no_peer_id = true;
|
||||||
}
|
}
|
||||||
// 7. TODO: support "compact" extension
|
// 7. TODO: support "compact" extension
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
#include <QHttpResponseHeader>
|
#include <QHttpResponseHeader>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
#include "httprequestparser.h"
|
|
||||||
#include "trackerannouncerequest.h"
|
#include "trackerannouncerequest.h"
|
||||||
#include "qpeer.h"
|
#include "qpeer.h"
|
||||||
|
|
||||||
@ -63,7 +62,7 @@ protected slots:
|
|||||||
void readRequest();
|
void readRequest();
|
||||||
void handlePeerConnection();
|
void handlePeerConnection();
|
||||||
void respondInvalidRequest(QTcpSocket *socket, int code, QString msg);
|
void respondInvalidRequest(QTcpSocket *socket, int code, QString msg);
|
||||||
void respondToAnnounceRequest(QTcpSocket *socket, const HttpRequestParser& parser);
|
void respondToAnnounceRequest(QTcpSocket *socket, const QHash<QString, QString>& get_parameters);
|
||||||
void ReplyWithPeerList(QTcpSocket *socket, const TrackerAnnounceRequest &annonce_req);
|
void ReplyWithPeerList(QTcpSocket *socket, const TrackerAnnounceRequest &annonce_req);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -91,7 +91,7 @@ void HttpConnection::read() {
|
|||||||
m_generator.setStatusLine(400, "Bad Request");
|
m_generator.setStatusLine(400, "Bad Request");
|
||||||
write();
|
write();
|
||||||
} else {
|
} else {
|
||||||
if (m_parser.isParsable())
|
if (!m_parser.isError())
|
||||||
respond();
|
respond();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,7 +129,6 @@ void HttpConnection::translateDocument(QString& data) {
|
|||||||
++context_index;
|
++context_index;
|
||||||
} while(translation == word && context_index < 15);
|
} while(translation == word && context_index < 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove keyboard shortcuts
|
// Remove keyboard shortcuts
|
||||||
translation.replace(mnemonic, "");
|
translation.replace(mnemonic, "");
|
||||||
|
|
||||||
@ -153,7 +152,7 @@ void HttpConnection::respond() {
|
|||||||
write();
|
write();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString auth = m_parser.value("Authorization");
|
QString auth = m_parser.header().value("Authorization");
|
||||||
if(auth.isEmpty()) {
|
if(auth.isEmpty()) {
|
||||||
// Return unauthorized header
|
// Return unauthorized header
|
||||||
qDebug("Auth is Empty...");
|
qDebug("Auth is Empty...");
|
||||||
@ -164,7 +163,7 @@ void HttpConnection::respond() {
|
|||||||
}
|
}
|
||||||
//qDebug("Auth: %s", qPrintable(auth.split(" ").first()));
|
//qDebug("Auth: %s", qPrintable(auth.split(" ").first()));
|
||||||
if (QString::compare(auth.split(" ").first(), "Digest", Qt::CaseInsensitive) != 0
|
if (QString::compare(auth.split(" ").first(), "Digest", Qt::CaseInsensitive) != 0
|
||||||
|| !m_httpserver->isAuthorized(auth.toLocal8Bit(), m_parser.method())) {
|
|| !m_httpserver->isAuthorized(auth.toLocal8Bit(), m_parser.header().method())) {
|
||||||
// Update failed attempt counter
|
// Update failed attempt counter
|
||||||
m_httpserver->increaseNbFailedAttemptsForIp(peer_ip);
|
m_httpserver->increaseNbFailedAttemptsForIp(peer_ip);
|
||||||
qDebug("client IP: %s (%d failed attempts)", qPrintable(peer_ip), nb_fail);
|
qDebug("client IP: %s (%d failed attempts)", qPrintable(peer_ip), nb_fail);
|
||||||
@ -567,19 +566,16 @@ void HttpConnection::respondCommand(const QString& command) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(command == "recheck"){
|
if(command == "recheck"){
|
||||||
recheckTorrent(m_parser.post("hash"));
|
QBtSession::instance()->recheckTorrent(m_parser.post("hash"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpConnection::recheckTorrent(const QString& hash) {
|
void HttpConnection::decreaseTorrentsPriority(const QStringList &hashes) {
|
||||||
QBtSession::instance()->recheckTorrent(hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HttpConnection::decreaseTorrentsPriority(const QStringList &hashes)
|
|
||||||
{
|
|
||||||
qDebug() << Q_FUNC_INFO << hashes;
|
qDebug() << Q_FUNC_INFO << hashes;
|
||||||
std::priority_queue<QPair<int, QTorrentHandle>, std::vector<QPair<int, QTorrentHandle> >, std::less<QPair<int, QTorrentHandle> > > torrent_queue;
|
std::priority_queue<QPair<int, QTorrentHandle>,
|
||||||
|
std::vector<QPair<int, QTorrentHandle> >,
|
||||||
|
std::less<QPair<int, QTorrentHandle> > > torrent_queue;
|
||||||
// Sort torrents by priority
|
// Sort torrents by priority
|
||||||
foreach(const QString &hash, hashes) {
|
foreach(const QString &hash, hashes) {
|
||||||
try {
|
try {
|
||||||
@ -602,7 +598,9 @@ void HttpConnection::decreaseTorrentsPriority(const QStringList &hashes)
|
|||||||
void HttpConnection::increaseTorrentsPriority(const QStringList &hashes)
|
void HttpConnection::increaseTorrentsPriority(const QStringList &hashes)
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << hashes;
|
qDebug() << Q_FUNC_INFO << hashes;
|
||||||
std::priority_queue<QPair<int, QTorrentHandle>, std::vector<QPair<int, QTorrentHandle> >, std::greater<QPair<int, QTorrentHandle> > > torrent_queue;
|
std::priority_queue<QPair<int, QTorrentHandle>,
|
||||||
|
std::vector<QPair<int, QTorrentHandle> >,
|
||||||
|
std::greater<QPair<int, QTorrentHandle> > > torrent_queue;
|
||||||
// Sort torrents by priority
|
// Sort torrents by priority
|
||||||
foreach(const QString &hash, hashes) {
|
foreach(const QString &hash, hashes) {
|
||||||
try {
|
try {
|
||||||
|
@ -65,7 +65,6 @@ protected slots:
|
|||||||
void respondNotFound();
|
void respondNotFound();
|
||||||
void processDownloadedFile(const QString& url, const QString& file_path);
|
void processDownloadedFile(const QString& url, const QString& file_path);
|
||||||
void handleDownloadFailure(const QString& url, const QString& reason);
|
void handleDownloadFailure(const QString& url, const QString& reason);
|
||||||
void recheckTorrent(const QString& hash);
|
|
||||||
void decreaseTorrentsPriority(const QStringList& hashes);
|
void decreaseTorrentsPriority(const QStringList& hashes);
|
||||||
void increaseTorrentsPriority(const QStringList& hashes);
|
void increaseTorrentsPriority(const QStringList& hashes);
|
||||||
|
|
||||||
|
@ -33,8 +33,7 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
HttpRequestParser::HttpRequestParser(): m_headerDone(false),
|
HttpRequestParser::HttpRequestParser(): m_error(false)
|
||||||
m_messageDone(false), m_error(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,11 +41,6 @@ HttpRequestParser::~HttpRequestParser()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HttpRequestParser::isParsable() const {
|
|
||||||
return !m_error && m_headerDone && isValid()
|
|
||||||
&& (m_messageDone || !hasContentLength() || contentLength() == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HttpRequestParser::isError() const {
|
bool HttpRequestParser::isError() const {
|
||||||
return m_error;
|
return m_error;
|
||||||
}
|
}
|
||||||
@ -56,71 +50,59 @@ QString HttpRequestParser::url() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QByteArray HttpRequestParser::message() const {
|
QByteArray HttpRequestParser::message() const {
|
||||||
if (isParsable())
|
return m_data;
|
||||||
return m_data;
|
|
||||||
return QByteArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString HttpRequestParser::get(const QString& key) const {
|
QString HttpRequestParser::get(const QString& key) const {
|
||||||
return m_getMap.value(key);
|
return m_getMap.value(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString HttpRequestParser::post(const QString& key) const {
|
QString HttpRequestParser::post(const QString& key) const {
|
||||||
return m_postMap.value(key);
|
return m_postMap.value(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray HttpRequestParser::torrent() const {
|
QByteArray HttpRequestParser::torrent() const {
|
||||||
return m_torrentContent;
|
return m_torrentContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpRequestParser::write(QByteArray ba) {
|
void HttpRequestParser::write(const QByteArray& ba) {
|
||||||
// Parse header
|
int end_of_header = ba.indexOf("\r\n\r\n");
|
||||||
while (!m_headerDone && !ba.isEmpty()) {
|
if (end_of_header < 0) {
|
||||||
const int index = ba.indexOf('\n') + 1;
|
qWarning() << "Could not find HTTP header: " << ba.constData();
|
||||||
if(index == 0) {
|
m_error = true;
|
||||||
m_data += ba;
|
return;
|
||||||
ba.clear();
|
}
|
||||||
} else {
|
|
||||||
m_data += ba.left(index);
|
|
||||||
ba.remove(0, index);
|
|
||||||
if(m_data.right(4) == "\r\n\r\n") {
|
|
||||||
QHttpRequestHeader::operator=(QHttpRequestHeader(m_data));
|
|
||||||
m_headerDone = true;
|
|
||||||
m_data.clear();
|
|
||||||
QUrl url = QUrl::fromEncoded(QHttpRequestHeader::path().toAscii());
|
|
||||||
m_path = url.path();
|
|
||||||
|
|
||||||
QListIterator<QPair<QString, QString> > i(url.queryItems());
|
// Parse header
|
||||||
while (i.hasNext()) {
|
m_header = QHttpRequestHeader(ba.left(end_of_header));
|
||||||
QPair<QString, QString> pair = i.next();
|
QUrl url = QUrl::fromEncoded(m_header.path().toAscii());
|
||||||
m_getMap[pair.first] = pair.second;
|
m_path = url.path();
|
||||||
}
|
|
||||||
}
|
// Parse GET parameters
|
||||||
}
|
QListIterator<QPair<QString, QString> > i(url.queryItems());
|
||||||
}
|
while (i.hasNext()) {
|
||||||
// Parse message
|
QPair<QString, QString> pair = i.next();
|
||||||
if(!m_messageDone && !ba.isEmpty()) {
|
m_getMap[pair.first] = pair.second;
|
||||||
if(hasContentLength()) {
|
}
|
||||||
m_data += ba;
|
|
||||||
if(m_data.size() >= (int) contentLength()) {
|
// Parse message content
|
||||||
m_data.resize(contentLength());
|
if (m_header.hasContentLength()) {
|
||||||
m_messageDone = true;
|
m_data = ba.mid(end_of_header + 4, m_header.contentLength()); // +4 to skip "\r\n\r\n"
|
||||||
//parse POST data
|
|
||||||
if(contentType() == "application/x-www-form-urlencoded") {
|
// Parse POST data
|
||||||
QUrl url;
|
if(m_header.contentType() == "application/x-www-form-urlencoded") {
|
||||||
url.setEncodedQuery(m_data);
|
QUrl url;
|
||||||
QListIterator<QPair<QString, QString> > i(url.queryItems());
|
url.setEncodedQuery(m_data);
|
||||||
while (i.hasNext()) {
|
QListIterator<QPair<QString, QString> > i(url.queryItems());
|
||||||
QPair<QString, QString> pair = i.next();
|
while (i.hasNext()) {
|
||||||
m_postMap[pair.first] = pair.second;
|
QPair<QString, QString> pair = i.next();
|
||||||
}
|
m_postMap[pair.first] = pair.second;
|
||||||
}
|
}
|
||||||
if(contentType() == "multipart/form-data") {
|
} else {
|
||||||
m_torrentContent = m_data.right(m_data.size()-m_data.indexOf("\r\n\r\n")-QByteArray("\r\n\r\n").size());
|
// Parse form data (torrent file)
|
||||||
}
|
if(m_header.contentType() == "multipart/form-data") {
|
||||||
}
|
m_torrentContent = m_data.right(m_data.size()-m_data.indexOf("\r\n\r\n")-QByteArray("\r\n\r\n").size());
|
||||||
} else {
|
}
|
||||||
m_error = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,23 +34,22 @@
|
|||||||
|
|
||||||
#include<QHttpRequestHeader>
|
#include<QHttpRequestHeader>
|
||||||
|
|
||||||
class HttpRequestParser : public QHttpRequestHeader {
|
class HttpRequestParser {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HttpRequestParser();
|
HttpRequestParser();
|
||||||
~HttpRequestParser();
|
~HttpRequestParser();
|
||||||
bool isParsable() const;
|
|
||||||
bool isError() const;
|
bool isError() const;
|
||||||
QString url() const;
|
QString url() const;
|
||||||
QByteArray message() const;
|
QByteArray message() const;
|
||||||
QString get(const QString& key) const;
|
QString get(const QString& key) const;
|
||||||
QString post(const QString& key) const;
|
QString post(const QString& key) const;
|
||||||
QByteArray torrent() const;
|
QByteArray torrent() const;
|
||||||
void write(QByteArray ba);
|
void write(const QByteArray& ba);
|
||||||
|
inline QHttpRequestHeader& header() { return m_header; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_headerDone;
|
QHttpRequestHeader m_header;
|
||||||
bool m_messageDone;
|
|
||||||
bool m_error;
|
bool m_error;
|
||||||
QByteArray m_data;
|
QByteArray m_data;
|
||||||
QString m_path;
|
QString m_path;
|
||||||
|
Loading…
Reference in New Issue
Block a user