forked from bablosoft/BAS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
httpclient.h
64 lines (54 loc) · 2.09 KB
/
httpclient.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef HTTPCLIENT_H
#define HTTPCLIENT_H
#include "ihttpclient.h"
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QList>
class HttpClient : public IHttpClient
{
Q_OBJECT
QNetworkAccessManager *network_manager;
bool was_error;
QString last_error;
QString page_content;
QString location;
int status;
QByteArray page_data;
bool disconnected;
QString LastUrl;
QHash<QString,QString> Headers;
QList<QPair<QByteArray, QByteArray> > ReturnHeaders;
IPostPrepareStrategyFactory* PostPrepareStrategyFactory;
QObject *request_holder;
public:
explicit HttpClient(QObject *parent = 0);
virtual void Get(const QString &url);
virtual void Download(const QString &url, const QString &file);
virtual void Post(const QString &url, const QHash<QString,QString> & params, const PostOptions & Options = PostOptions());
virtual void Post(const QString &url, const QHash<QString,ContentData> & params, const PostOptions & Options = PostOptions());
virtual QByteArray GetPageData();
virtual void Connect(QObject *object, const char * slot);
virtual void Disconnect();
virtual void Stop();
signals:
public slots:
virtual bool WasError();
virtual QString GetErrorString();
virtual QString GetContent();
virtual QString GetBase64();
virtual int GetStatus();
virtual QString GetHeader(const QString& header);
virtual QString GetLastUrl();
virtual void AddHeader(const QString& name,const QString& value);
virtual void CleanHeader();
virtual void SetProxy(const QString& server, int Port, bool IsHttp, const QString& name, const QString& password);
virtual QString GetCookiesForUrl(const QString& url);
virtual void SetPostPrepareStrategyFactory(IPostPrepareStrategyFactory* PostPrepareStrategyFactory);
virtual QString SaveCookies();
virtual void RestoreCookies(const QString& cookies);
private slots:
void sslErrors(QNetworkReply* reply,const QList<QSslError> &errors);
void FinishedSlot();
QPair<bool, ContentData> ParsePostArgument(const QString& str);
};
#endif // HTTPCLIENT_H