polybar-dwm/include/utils/http.hpp
patrick96 0d1db206c6 Remove factory_util unique and shared
Equivalent to std::make_unique and std::make_shared
2021-09-21 21:43:27 +02:00

31 lines
628 B
C++

#pragma once
#include "common.hpp"
#include "utils/factory.hpp"
POLYBAR_NS
class http_downloader {
public:
http_downloader(int connection_timeout = 5);
~http_downloader();
string get(const string& url, const string& user = "", const string& password = "");
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) {
return std::make_unique<http_downloader>(forward<Args>(args)...);
}
} // namespace http_util
POLYBAR_NS_END