add httpGet error handling
This commit is contained in:
+12
-3
@@ -9,13 +9,18 @@
|
||||
#include "util/Buffer.hpp"
|
||||
|
||||
namespace network {
|
||||
using OnResponse = std::function<void(int, std::vector<char>)>;
|
||||
using OnResponse = std::function<void(std::vector<char>)>;
|
||||
using OnReject = std::function<void(const char*)>;
|
||||
|
||||
class Http {
|
||||
public:
|
||||
virtual ~Http() {}
|
||||
|
||||
virtual void get(const std::string& url, const OnResponse& callback) = 0;
|
||||
virtual void get(
|
||||
const std::string& url,
|
||||
OnResponse onResponse,
|
||||
OnReject onReject=nullptr
|
||||
) = 0;
|
||||
virtual size_t getTotalUpload() const = 0;
|
||||
virtual size_t getTotalDownload() const = 0;
|
||||
};
|
||||
@@ -26,7 +31,11 @@ namespace network {
|
||||
Network(std::unique_ptr<Http> http);
|
||||
~Network();
|
||||
|
||||
void httpGet(const std::string& url, const OnResponse& callback);
|
||||
void httpGet(
|
||||
const std::string& url,
|
||||
OnResponse onResponse,
|
||||
OnReject onReject = nullptr
|
||||
);
|
||||
|
||||
size_t getTotalUpload() const;
|
||||
size_t getTotalDownload() const;
|
||||
|
||||
Reference in New Issue
Block a user