libktorrent  2.1.1
httprequest.h
1 /***************************************************************************
2  * Copyright (C) 2005-2007 by Joris Guisson *
3  * joris.guisson@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #ifndef KTHTTPREQUEST_H
22 #define KTHTTPREQUEST_H
23 
24 #include <QNetworkAccessManager>
25 #include <QNetworkRequest>
26 
27 #include <interfaces/exitoperation.h>
28 #include <util/constants.h>
29 
30 
31 namespace bt
32 {
33 
40  class HTTPRequest : public bt::ExitOperation
41  {
42  Q_OBJECT
43  public:
52  HTTPRequest(const QNetworkRequest & hdr,const QString & payload,const QString & host,
53  bt::Uint16 port,bool verbose);
57  void start();
58 
59 
63  QByteArray replyData() const {return reply;}
64 
68  bool succeeded() const {return success;}
69 
73  QString errorString() const {return error;}
74 
75  Q_SIGNALS:
80  void result(HTTPRequest* r);
81 
82 
83  public:
84  void replyFinished(QNetworkReply *networkReply);
85 
86  private:
87  void parseReply(int eoh);
88 
89  private:
90  QNetworkRequest hdr;
91  QString m_payload;
92  bool verbose;
93  QString host;
94  bt::Uint16 port;
95  QNetworkAccessManager *networkAccessManager;
96  QByteArray reply;
97  bool success;
98  QString error;
99  };
100 }
101 
102 #endif
bt::HTTPRequest::errorString
QString errorString() const
Definition: httprequest.h:109
bt::HTTPRequest::succeeded
bool succeeded() const
Definition: httprequest.h:104
bt::HTTPRequest::result
void result(HTTPRequest *r)
bt::HTTPRequest::HTTPRequest
HTTPRequest(const QNetworkRequest &hdr, const QString &payload, const QString &host, bt::Uint16 port, bool verbose)
bt::HTTPRequest::replyData
QByteArray replyData() const
Definition: httprequest.h:99
bt::HTTPRequest::start
void start()
bt::ExitOperation
Definition: exitoperation.h:58