Fix compilation for curl 7.68.0
This commit is contained in:
parent
0dd921cd5d
commit
5d74e1124d
12
client.cpp
12
client.cpp
|
@ -43,9 +43,15 @@ MastodonClient::MastodonClient() {
|
||||||
try {
|
try {
|
||||||
setopt(this->_share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
|
setopt(this->_share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
|
||||||
setopt(this->_share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
|
setopt(this->_share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
|
||||||
|
#if CURL_AT_LEAST_VERSION(7, 57, 0)
|
||||||
setopt(this->_share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);
|
setopt(this->_share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);
|
||||||
|
#endif
|
||||||
|
#if CURL_AT_LEAST_VERSION(7, 61, 0)
|
||||||
setopt(this->_share, CURLSHOPT_SHARE, CURL_LOCK_DATA_PSL);
|
setopt(this->_share, CURLSHOPT_SHARE, CURL_LOCK_DATA_PSL);
|
||||||
|
#endif
|
||||||
|
#if CURL_AT_LEAST_VERSION(7, 88, 0)
|
||||||
setopt(this->_share, CURLSHOPT_SHARE, CURL_LOCK_DATA_HSTS);
|
setopt(this->_share, CURLSHOPT_SHARE, CURL_LOCK_DATA_HSTS);
|
||||||
|
#endif
|
||||||
|
|
||||||
setopt(this->_share, CURLSHOPT_LOCKFUNC, share_lock);
|
setopt(this->_share, CURLSHOPT_LOCKFUNC, share_lock);
|
||||||
setopt(this->_share, CURLSHOPT_UNLOCKFUNC, share_unlock);
|
setopt(this->_share, CURLSHOPT_UNLOCKFUNC, share_unlock);
|
||||||
|
@ -206,7 +212,11 @@ CURL* MastodonClient::_get_easy() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setopt(curl, CURLOPT_TIMEOUT_MS, 10000L);
|
setopt(curl, CURLOPT_TIMEOUT_MS, 10000L);
|
||||||
|
#if CURL_AT_LEAST_VERSION(7, 85, 0)
|
||||||
setopt(curl, CURLOPT_PROTOCOLS_STR, "https");
|
setopt(curl, CURLOPT_PROTOCOLS_STR, "https");
|
||||||
|
#else
|
||||||
|
setopt(curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
|
||||||
|
#endif
|
||||||
setopt(curl, CURLOPT_USERAGENT, "Coyote (https://gitlab.com/blankX/coyote; blankie@nixnetmail.com)");
|
setopt(curl, CURLOPT_USERAGENT, "Coyote (https://gitlab.com/blankX/coyote; blankie@nixnetmail.com)");
|
||||||
setopt(curl, CURLOPT_SHARE, this->_share);
|
setopt(curl, CURLOPT_SHARE, this->_share);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
|
@ -266,7 +276,7 @@ long MastodonClient::_response_status_code() {
|
||||||
static void lowercase(std::string& str) {
|
static void lowercase(std::string& str) {
|
||||||
for (size_t i = 0; i < str.size(); i++) {
|
for (size_t i = 0; i < str.size(); i++) {
|
||||||
if (str[i] >= 'A' && str[i] <= 'Z') {
|
if (str[i] >= 'A' && str[i] <= 'Z') {
|
||||||
str[i] = str[i] - static_cast<char>('A' + 'a');
|
str[i] = static_cast<char>(str[i] - 'A' + 'a');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,6 @@ private:
|
||||||
lxb_html_document_t* _document;
|
lxb_html_document_t* _document;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace HTML
|
} // namespace HTML
|
||||||
|
|
||||||
}; // namespace LXB
|
} // namespace LXB
|
||||||
|
|
2
models.h
2
models.h
|
@ -41,7 +41,7 @@ struct Account {
|
||||||
std::vector<Emoji> emojis;
|
std::vector<Emoji> emojis;
|
||||||
std::vector<AccountField> fields;
|
std::vector<AccountField> fields;
|
||||||
|
|
||||||
constexpr std::string acct(bool always_show_domain = true) const {
|
inline std::string acct(bool always_show_domain = true) const {
|
||||||
std::string res = this->username;
|
std::string res = this->username;
|
||||||
if (always_show_domain || !this->same_server) {
|
if (always_show_domain || !this->same_server) {
|
||||||
res += '@';
|
res += '@';
|
||||||
|
|
|
@ -29,13 +29,26 @@ static inline Element serialize_poll(const httplib::Request& req, const Poll& po
|
||||||
|
|
||||||
class CurlUrlException : public std::exception {
|
class CurlUrlException : public std::exception {
|
||||||
public:
|
public:
|
||||||
CurlUrlException(CURLUcode code_) : code(code_) {}
|
CurlUrlException(CURLUcode code_) : code(code_) {
|
||||||
|
#if !CURL_AT_LEAST_VERSION(7, 80, 0)
|
||||||
|
snprintf(this->_id_buf, 64, "curl url error %d", this->code);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
const char* what() const noexcept {
|
const char* what() const noexcept {
|
||||||
|
#if CURL_AT_LEAST_VERSION(7, 80, 0)
|
||||||
return curl_url_strerror(this->code);
|
return curl_url_strerror(this->code);
|
||||||
|
#else
|
||||||
|
return this->_id_buf;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
CURLUcode code;
|
CURLUcode code;
|
||||||
|
|
||||||
|
private:
|
||||||
|
#if !CURL_AT_LEAST_VERSION(7, 80, 0)
|
||||||
|
char _id_buf[64];
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue