diff --git a/loader/include/Geode/utils/web.hpp b/loader/include/Geode/utils/web.hpp index de421693..98cded4f 100644 --- a/loader/include/Geode/utils/web.hpp +++ b/loader/include/Geode/utils/web.hpp @@ -203,6 +203,15 @@ namespace geode::utils::web { */ WebRequest& followRedirects(bool enabled); + /** + * Enables or disables ignoring the content length header. + * The default is false. + * + * @param enabled + * @return WebRequest& + */ + WebRequest& ignoreContentLength(bool enabled); + /** * Sets the Certificate Authority (CA) bundle content. * Defaults to not sending a CA bundle. diff --git a/loader/src/utils/web.cpp b/loader/src/utils/web.cpp index 02028859..aadd10b9 100644 --- a/loader/src/utils/web.cpp +++ b/loader/src/utils/web.cpp @@ -202,6 +202,7 @@ public: bool m_certVerification = true; bool m_transferBody = true; bool m_followRedirects = true; + bool m_ignoreContentLength = false; std::string m_CABundleContent; ProxyOpts m_proxyOpts = {}; HttpVersion m_httpVersion = HttpVersion::DEFAULT; @@ -382,6 +383,9 @@ WebTask WebRequest::send(std::string_view method, std::string_view url) { // Follow request through 3xx responses curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, impl->m_followRedirects ? 1L : 0L); + // Ignore content length + curl_easy_setopt(curl, CURLOPT_IGNORE_CONTENT_LENGTH, impl->m_ignoreContentLength ? 1L : 0L); + // Track progress curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); @@ -556,6 +560,11 @@ WebRequest& WebRequest::followRedirects(bool enabled) { return *this; } +WebRequest& WebRequest::ignoreContentLength(bool enabled) { + m_impl->m_ignoreContentLength = enabled; + return *this; +} + WebRequest& WebRequest::CABundleContent(std::string_view content) { m_impl->m_CABundleContent = content; return *this;