Merge pull request #1126 from hiimjustin000/ignore-length

WebRequest::ignoreContentLength
This commit is contained in:
fig 2024-11-07 11:40:58 -05:00 committed by GitHub
commit 44a70d391b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View file

@ -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.

View file

@ -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;