]> git.sur5r.net Git - minitube/blob - lib/http/src/networkhttpreply.h
New upstream version 3.4
[minitube] / lib / http / src / networkhttpreply.h
1 #ifndef NETWORKHTTPREPLY_H
2 #define NETWORKHTTPREPLY_H
3
4 #include <QtNetwork>
5
6 #include "http.h"
7 #include "httpreply.h"
8 #include "httprequest.h"
9
10 class NetworkHttpReply : public HttpReply {
11     Q_OBJECT
12
13 public:
14     NetworkHttpReply(const HttpRequest &req, Http &http);
15     QUrl url() const;
16     int statusCode() const;
17     QString reasonPhrase() const;
18     const QList<QNetworkReply::RawHeaderPair> headers() const;
19     QByteArray header(const QByteArray &headerName) const;
20     QByteArray body() const;
21
22 private slots:
23     void replyFinished();
24     void replyError(QNetworkReply::NetworkError);
25     void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
26     void readTimeout();
27
28 private:
29     void setupReply();
30     QString errorMessage();
31     void emitError();
32     void emitFinished();
33
34     Http &http;
35     HttpRequest req;
36     QNetworkReply *networkReply;
37     QTimer *readTimeoutTimer;
38     int retryCount;
39     QByteArray bytes;
40 };
41
42 #endif // NETWORKHTTPREPLY_H