-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpRequest.h
More file actions
31 lines (21 loc) · 891 Bytes
/
HttpRequest.h
File metadata and controls
31 lines (21 loc) · 891 Bytes
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
#ifndef QT_UTILS_HTTP_REQUEST_H
#define QT_UTILS_HTTP_REQUEST_H
#include "./Setup.h"
#include <QString>
#include <QNetworkReply>
QT_UTILS_NAMESPACE_BEGIN
//!
//! Defines the signature of a function like object that will be called when
//! a request has been successfully retrieved.
//!
typedef std::function< void (QByteArray reply) > SuccessCallback;
//!
//! Defines the signature of a function like object that will be called when
//! a request couldn't be completed.
//!
typedef std::function< void (QNetworkReply::NetworkError error, QString errorString) > FailureCallback;
// helpers
QByteArray RequestUrl(const QString & url, QNetworkAccessManager * networkManager = nullptr);
void RequestUrl(const QString & url, const SuccessCallback & success, const FailureCallback & failure, QNetworkAccessManager * networkManager = nullptr);
QT_UTILS_NAMESPACE_END
#endif