2016-12-19 16:01:37 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common.hpp"
|
|
|
|
|
|
|
|
POLYBAR_NS
|
|
|
|
|
|
|
|
class http_downloader {
|
|
|
|
public:
|
|
|
|
http_downloader(int connection_timeout = 5);
|
|
|
|
~http_downloader();
|
|
|
|
|
2020-03-26 07:50:42 -04:00
|
|
|
string get(const string& url, const string& user = "", const string& password = "");
|
2016-12-19 16:01:37 -05:00
|
|
|
long response_code();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static size_t write(void* p, size_t size, size_t bytes, void* stream);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void* m_curl;
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace http_util {
|
|
|
|
template <typename... Args>
|
|
|
|
decltype(auto) make_downloader(Args&&... args) {
|
2021-09-21 15:15:49 -04:00
|
|
|
return std::make_unique<http_downloader>(forward<Args>(args)...);
|
2016-12-19 16:01:37 -05:00
|
|
|
}
|
2020-03-26 07:50:42 -04:00
|
|
|
} // namespace http_util
|
2016-12-19 16:01:37 -05:00
|
|
|
|
|
|
|
POLYBAR_NS_END
|