fix android build, free curl header list

This commit is contained in:
matcool 2024-02-03 19:14:58 -03:00
parent 17153a4f68
commit 1ce2b32a7f
2 changed files with 10 additions and 4 deletions
loader/src

View file

@ -61,8 +61,13 @@ void updater::fetchLatestGithubRelease(
.header("If-Modified-Since", modifiedSince)
.userAgent("github_api/1.0")
.fetch("https://api.github.com/repos/geode-sdk/geode/releases/latest")
.json()
.then([then](web::SentAsyncWebRequest& req, matjson::Value const& json) {
.text()
.then([then, expect](web::SentAsyncWebRequest& req, std::string const& text) {
if (text.empty()) {
expect("Empty response");
return;
}
auto json = matjson::parse(text);
Mod::get()->setSavedValue("last-modified-auto-update-check", req.getResponseHeader("Last-Modified"));
s_latestGithubRelease = json;
then(json);

View file

@ -334,7 +334,7 @@ SentAsyncWebRequest::Impl::Impl(SentAsyncWebRequest* self, AsyncWebRequest const
} data{this, file.get()};
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &data);
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, +[](char* buffer, size_t size, size_t nitems, void* ptr){
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, (+[](char* buffer, size_t size, size_t nitems, void* ptr){
auto data = static_cast<ProgressData*>(ptr);
std::unordered_map<std::string, std::string> headers;
std::string line;
@ -350,7 +350,7 @@ SentAsyncWebRequest::Impl::Impl(SentAsyncWebRequest* self, AsyncWebRequest const
data->self->m_responseHeader[key] = value;
}
return size * nitems;
});
}));
curl_easy_setopt(
curl,
@ -396,6 +396,7 @@ SentAsyncWebRequest::Impl::Impl(SentAsyncWebRequest* self, AsyncWebRequest const
curl_easy_cleanup(curl);
return this->error(response_str, code);
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
AWAIT_RESUME();