This commit is contained in:
Justin 2024-11-01 18:52:50 +00:00
parent fd2a457e76
commit 7566292157
2 changed files with 18 additions and 0 deletions

View file

@ -203,6 +203,15 @@ namespace geode::utils::web {
*/ */
WebRequest& followRedirects(bool enabled); 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. * Sets the Certificate Authority (CA) bundle content.
* Defaults to not sending a CA bundle. * Defaults to not sending a CA bundle.

View file

@ -202,6 +202,7 @@ public:
bool m_certVerification = true; bool m_certVerification = true;
bool m_transferBody = true; bool m_transferBody = true;
bool m_followRedirects = true; bool m_followRedirects = true;
bool m_ignoreContentLength = false;
std::string m_CABundleContent; std::string m_CABundleContent;
ProxyOpts m_proxyOpts = {}; ProxyOpts m_proxyOpts = {};
HttpVersion m_httpVersion = HttpVersion::DEFAULT; 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 // Follow request through 3xx responses
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, impl->m_followRedirects ? 1L : 0L); 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 // Track progress
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
@ -556,6 +560,11 @@ WebRequest& WebRequest::followRedirects(bool enabled) {
return *this; return *this;
} }
WebRequest& WebRequest::ignoreContentLength(bool enabled) {
m_impl->m_ignoreContentLength = enabled;
return *this;
}
WebRequest& WebRequest::CABundleContent(std::string_view content) { WebRequest& WebRequest::CABundleContent(std::string_view content) {
m_impl->m_CABundleContent = content; m_impl->m_CABundleContent = content;
return *this; return *this;