@@ -339,14 +339,34 @@ ofHttpResponse ofURLFileLoaderImpl::handleRequest(const ofHttpRequest & request)
339339 if (request.contentType != " " ) {
340340 headers = curl_slist_append (headers, (" Content-Type: " + request.contentType ).c_str ());
341341 }
342- if (request.close )
342+ if (request.close ) {
343343 headers = curl_slist_append (headers, " Connection: close" );
344- if (version->features & CURL_VERSION_BROTLI) {
345- headers = curl_slist_append (headers, " Accept-Encoding: br" );
346- }
347- if (version->features & CURL_VERSION_LIBZ) {
348- headers = curl_slist_append (headers, " Accept-Encoding: gzip" );
349344 }
345+ // https://curl.se/libcurl/c/CURLOPT_ACCEPT_ENCODING.html
346+ // the following is used for requesting specific compression encodings
347+ // if the headers are set with the encodings, then curl will not decompress the received data
348+ // leaving this here for future reference
349+ // std::string encodings = "Accept-Encoding: ";
350+ // bool first = true;
351+ //
352+ // if (version->features & CURL_VERSION_BROTLI) {
353+ // encodings += "br";
354+ // first = false;
355+ // }
356+ // if (version->features & CURL_VERSION_LIBZ) {
357+ // if (!first) {encodings += ", ";}
358+ // encodings += "gzip";
359+ // first = false;
360+ // }
361+ // if( !first) {
362+ // ofLogVerbose("ofURLFileLoader :: encodings") << encodings;
363+ // headers = curl_slist_append(headers, encodings.c_str());
364+ // } else {
365+ // curl_easy_setopt(curl.get(), CURLOPT_ACCEPT_ENCODING, "");
366+ // }
367+ /* enable all supported built-in compressions */
368+ curl_easy_setopt (curl.get (), CURLOPT_ACCEPT_ENCODING, " " );
369+
350370 for (map<string, string>::const_iterator it = request.headers .cbegin (); it != request.headers .cend (); it++) {
351371 headers = curl_slist_append (headers, (it->first + " : " + it->second ).c_str ());
352372 }
0 commit comments