fix: Proxy not being disabled correctly when disabling it in the settings

This commit is contained in:
WerWolv
2023-11-10 21:59:20 +01:00
parent 01f7a09012
commit ec4942174b
4 changed files with 22 additions and 12 deletions

View File

@@ -73,7 +73,8 @@ namespace hex {
HttpRequest& operator=(HttpRequest &&other) noexcept;
static void setProxy(std::string proxy);
static void setProxyState(bool enabled);
static void setProxyUrl(std::string proxy);
void setMethod(std::string method) {
this->m_method = std::move(method);

View File

@@ -40,10 +40,14 @@ namespace hex {
});
}
void HttpRequest::setProxy(std::string proxy) {
void HttpRequest::setProxyUrl(std::string proxy) {
hex::unused(proxy);
}
void HttpRequest::setProxyState(bool state) {
hex::unused(state);
}
void HttpRequest::checkProxyErrors() { }
int HttpRequest::progressCallback(void *contents, curl_off_t dlTotal, curl_off_t dlNow, curl_off_t ulTotal, curl_off_t ulNow) {

View File

@@ -5,7 +5,10 @@
namespace hex {
namespace {
std::string s_proxyUrl;
bool s_proxyState;
}
HttpRequest::HttpRequest(std::string method, std::string url) : m_method(std::move(method)), m_url(std::move(url)) {
@@ -60,7 +63,9 @@ namespace hex {
curl_easy_setopt(this->m_curl, CURLOPT_NOPROGRESS, 0L);
curl_easy_setopt(this->m_curl, CURLOPT_XFERINFODATA, this);
curl_easy_setopt(this->m_curl, CURLOPT_XFERINFOFUNCTION, progressCallback);
curl_easy_setopt(this->m_curl, CURLOPT_PROXY, s_proxyUrl.c_str());
if (s_proxyState)
curl_easy_setopt(this->m_curl, CURLOPT_PROXY, s_proxyUrl.c_str());
}
std::future<HttpRequest::Result<std::vector<u8>>> HttpRequest::downloadFile() {
@@ -76,12 +81,16 @@ namespace hex {
void HttpRequest::setProxy(std::string proxy) {
void HttpRequest::setProxyUrl(std::string proxy) {
s_proxyUrl = std::move(proxy);
}
void HttpRequest::setProxyState(bool state) {
s_proxyState = state;
}
void HttpRequest::checkProxyErrors() {
if (!s_proxyUrl.empty()){
if (s_proxyState && !s_proxyUrl.empty()){
log::info("A custom proxy '{0}' is in use. Is it working correctly?", s_proxyUrl);
}
}