-
Notifications
You must be signed in to change notification settings - Fork 0
/
chunk.h
47 lines (35 loc) · 1.04 KB
/
chunk.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef CHUNK_H
#define CHUNK_H
#include <QFile>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QObject>
#include <QUuid>
class Chunk : public QObject
{
Q_OBJECT
public:
explicit Chunk(const QUrl &url, const QString &dir, QObject *parent = nullptr);
bool request();
QString fileName() const;
QUuid uuid() const;
void setHeader(const QByteArray &key, const QByteArray &value);
signals:
void resultIsReady(const QUuid &uuid);
private:
void replyFinished();
void replyReadyRead();
void sslErrors(const QList<QSslError> &errors);
void processErrors(QNetworkReply::NetworkError error);
QUrl m_url;
QUuid m_uuid;
QFile m_file;
QHash<QByteArray, QByteArray> m_requestHeaders;
QNetworkAccessManager m_qnam; // two instances in one thread, is OK ?
QNetworkReply *m_reply = nullptr;
QString m_dir;
// TODO
// сравнить с Content-Length и если отличается писать об этом ворнинг
int m_totalBytes = 0;
};
#endif // CHUNK_H