Browse Source

Use the new Http classes.

adaptive-webui-19844
sledgehammer999 11 years ago
parent
commit
e8c14f3507
  1. 9
      src/tracker/qtracker.cpp
  2. 1
      src/tracker/qtracker.h
  3. 4
      src/webui/httpconnection.cpp
  4. 2
      src/webui/httprequestparser.cpp
  5. 6
      src/webui/httprequestparser.h
  6. 2
      src/webui/httpresponsegenerator.cpp
  7. 4
      src/webui/httpresponsegenerator.h

9
src/tracker/qtracker.cpp

@ -28,7 +28,6 @@ @@ -28,7 +28,6 @@
* Contact : chris@qbittorrent.org
*/
#include <QHttpRequestHeader>
#include <QTcpSocket>
#include <QUrl>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
@ -38,6 +37,8 @@ @@ -38,6 +37,8 @@
#include <libtorrent/bencode.hpp>
#include <libtorrent/entry.hpp>
#include "httprequestheader.h"
#include "httpresponseheader.h"
#include "qtracker.h"
#include "preferences.h"
@ -90,7 +91,7 @@ void QTracker::readRequest() @@ -90,7 +91,7 @@ void QTracker::readRequest()
QTcpSocket *socket = static_cast<QTcpSocket*>(sender());
QByteArray input = socket->readAll();
//qDebug("QTracker: Raw request:\n%s", input.data());
QHttpRequestHeader http_request(input);
HttpRequestHeader http_request(input);
if (!http_request.isValid()) {
qDebug("QTracker: Invalid HTTP Request:\n %s", qPrintable(http_request.toString()));
respondInvalidRequest(socket, 100, "Invalid request type");
@ -129,7 +130,7 @@ void QTracker::readRequest() @@ -129,7 +130,7 @@ void QTracker::readRequest()
void QTracker::respondInvalidRequest(QTcpSocket *socket, int code, QString msg)
{
QHttpResponseHeader response;
HttpResponseHeader response;
response.setStatusLine(code, msg);
socket->write(response.toString().toLocal8Bit());
socket->disconnectFromHost();
@ -246,7 +247,7 @@ void QTracker::ReplyWithPeerList(QTcpSocket *socket, const TrackerAnnounceReques @@ -246,7 +247,7 @@ void QTracker::ReplyWithPeerList(QTcpSocket *socket, const TrackerAnnounceReques
QByteArray reply(&buf[0], buf.size());
qDebug("QTracker: reply with the following bencoded data:\n %s", reply.constData());
// HTTP reply
QHttpResponseHeader response;
HttpResponseHeader response;
response.setStatusLine(200, "OK");
socket->write(response.toString().toLocal8Bit() + reply);
socket->disconnectFromHost();

1
src/tracker/qtracker.h

@ -32,7 +32,6 @@ @@ -32,7 +32,6 @@
#define QTRACKER_H
#include <QTcpServer>
#include <QHttpResponseHeader>
#include <QHash>
#include "trackerannouncerequest.h"

4
src/webui/httpconnection.cpp

@ -31,6 +31,8 @@ @@ -31,6 +31,8 @@
#include "httpconnection.h"
#include "httpserver.h"
#include "httprequestheader.h"
#include "httpresponseheader.h"
#include "preferences.h"
#include "btjson.h"
#include "prefjson.h"
@ -42,8 +44,6 @@ @@ -42,8 +44,6 @@
#include <QTcpSocket>
#include <QDateTime>
#include <QStringList>
#include <QHttpRequestHeader>
#include <QHttpResponseHeader>
#include <QFile>
#include <QDebug>
#include <QRegExp>

2
src/webui/httprequestparser.cpp

@ -71,7 +71,7 @@ const QList<QByteArray>& HttpRequestParser::torrents() const { @@ -71,7 +71,7 @@ const QList<QByteArray>& HttpRequestParser::torrents() const {
void HttpRequestParser::writeHeader(const QByteArray& ba) {
m_error = false;
// Parse header
m_header = QHttpRequestHeader(ba);
m_header = HttpRequestHeader(ba);
QUrl url = QUrl::fromEncoded(m_header.path().toLatin1());
m_path = url.path();

6
src/webui/httprequestparser.h

@ -32,8 +32,8 @@ @@ -32,8 +32,8 @@
#ifndef HTTPREQUESTPARSER_H
#define HTTPREQUESTPARSER_H
#include <QHttpRequestHeader>
#include <QHash>
#include "httprequestheader.h"
class HttpRequestParser {
@ -49,10 +49,10 @@ public: @@ -49,10 +49,10 @@ public:
void writeHeader(const QByteArray& ba);
void writeMessage(const QByteArray& ba);
bool acceptsEncoding();
inline const QHttpRequestHeader& header() const { return m_header; }
inline const HttpRequestHeader& header() const { return m_header; }
private:
QHttpRequestHeader m_header;
HttpRequestHeader m_header;
bool m_error;
QByteArray m_data;
QString m_path;

2
src/webui/httpresponsegenerator.cpp

@ -136,5 +136,5 @@ QByteArray HttpResponseGenerator::toByteArray() { @@ -136,5 +136,5 @@ QByteArray HttpResponseGenerator::toByteArray() {
}
setContentLength(m_message.size());
return QHttpResponseHeader::toString().toUtf8() + m_message;
return HttpResponseHeader::toString().toUtf8() + m_message;
}

4
src/webui/httpresponsegenerator.h

@ -32,9 +32,9 @@ @@ -32,9 +32,9 @@
#ifndef HTTPRESPONSEGENERATOR_H
#define HTTPRESPONSEGENERATOR_H
#include<QHttpResponseHeader>
#include "httpresponseheader.h"
class HttpResponseGenerator : public QHttpResponseHeader
class HttpResponseGenerator : public HttpResponseHeader
{
public:

Loading…
Cancel
Save