-
Notifications
You must be signed in to change notification settings - Fork 0
/
wget.h
48 lines (42 loc) · 824 Bytes
/
wget.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
48
#ifndef WGET_H
#define WGET_H
#include <QObject>
#include <QTcpSocket>
struct RequestLine{
QString proto = "HTTP/1.1";
QString url;
QString type;
};
struct ResponseLine{
QString proto = "";
uint16_t code = 0;
QString reason;
};
struct HttpPacket{
RequestLine request;
ResponseLine response;
QString contType;
unsigned long int contLen;
QByteArray body;
};
class Wget : public QObject
{
Q_OBJECT
public:
explicit Wget(QObject *parent = 0);
bool isRunning() { return m_running; }
void get(QString url);
QByteArray getBody() { return m_packet.body; }
signals:
void signal_complete();
private slots:
void slot_readyRead();
private:
QTcpSocket* m_pSocket;
bool m_running = false;
HttpPacket m_packet;
QByteArray m_buffer;
void parsHead(const QByteArray &data);
void clearData();
};
#endif // WGET_H