1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-18 13:55:11 -05:00
polybar/include/utils/http.hpp
Lucas Araújo 15496bfb4a
Update: Using another way to authenticate github module (#2029)
The github module only authenticate by query string, and this method is deprecated:
https://developer.github.com/changes/2019-11-05-deprecated-passwords-and-authorizations-api/#authenticating-using-query-parameters


There is no reason to remove it before the method stop working, so I've made possible to the user choose which authentication method he will use:

* The parameter token remain unchanged.
* If the parameter user is passed then the module will use the not deprecated method, passing user and token on the body of the requisition. Otherwise the module will use the deprecated method.

Co-authored-by: Lucas <araujo.lucasvale@gmail.com>

Fixes #2002
2020-03-26 12:50:42 +01:00

30 lines
632 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 factory_util::unique<http_downloader>(forward<Args>(args)...);
}
} // namespace http_util
POLYBAR_NS_END