Skip to content

Commit

Permalink
set CURLOPT_ENCODING to nullptr in case of curl7 (#2737)
Browse files Browse the repository at this point in the history
* set CURLOPT_ENCODING to nullptr in case of curl7

Curl 7 introduced more strictness how it handles CURLOPT_ENCODING.

With earlier versions it as apparently okay when the server sent an encoding curl did not implement.

Newer versions are much more stricter and refuse to complete downloads under such circumstances. This leads to almost nothing loading.
The culrpit seemingly being either the simulator or asset servers sending headers curls does not accept.

The workaround is to set CURLOPT_ENCODING to nullptr rather than "". This does come with the implication that curl will not handle decompression transparently, rather this burden gets shifted to the application.
It will also not send Accept-Encoding headers automatically.

* Adapt a few more occurences of CURLOPT_ENCODING for curl >= 7
  • Loading branch information
Nicky-D authored Nov 15, 2024
1 parent 7ff655a commit 7bdd2b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 11 additions & 1 deletion indra/llcorehttp/_httpoprequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,12 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
check_curl_easy_setopt(mCurlHandle, CURLOPT_NOPROGRESS, 1);
check_curl_easy_setopt(mCurlHandle, CURLOPT_URL, mReqURL.c_str());
check_curl_easy_setopt(mCurlHandle, CURLOPT_PRIVATE, getHandle());
check_curl_easy_setopt(mCurlHandle, CURLOPT_ENCODING, "");

#if LIBCURL_VERSION_MAJOR > 7
check_curl_easy_setopt(mCurlHandle, CURLOPT_ENCODING, nullptr);
#else
check_curl_easy_setopt(mCurlHandle, CURLOPT_ENCODING, "");
#endif

check_curl_easy_setopt(mCurlHandle, CURLOPT_AUTOREFERER, 1);
check_curl_easy_setopt(mCurlHandle, CURLOPT_MAXREDIRS, HTTP_REDIRECTS_DEFAULT);
Expand Down Expand Up @@ -603,7 +608,12 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
case HOR_POST:
{
check_curl_easy_setopt(mCurlHandle, CURLOPT_POST, 1);

#if LIBCURL_VERSION_MAJOR > 7
check_curl_easy_setopt(mCurlHandle, CURLOPT_ENCODING, nullptr);
#else
check_curl_easy_setopt(mCurlHandle, CURLOPT_ENCODING, "");
#endif
long data_size(0);
if (mReqBody)
{
Expand Down
6 changes: 6 additions & 0 deletions indra/llcorehttp/httpcommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,13 @@ CURL *getCurlTemplateHandle()
check_curl_code(result, CURLOPT_NOSIGNAL);
result = curl_easy_setopt(curlpTemplateHandle, CURLOPT_NOPROGRESS, 1);
check_curl_code(result, CURLOPT_NOPROGRESS);

#if LIBCURL_VERSION_MAJOR > 7
result = curl_easy_setopt(curlpTemplateHandle, CURLOPT_ENCODING, nullptr);
#else
result = curl_easy_setopt(curlpTemplateHandle, CURLOPT_ENCODING, "");
#endif

check_curl_code(result, CURLOPT_ENCODING);
result = curl_easy_setopt(curlpTemplateHandle, CURLOPT_AUTOREFERER, 1);
check_curl_code(result, CURLOPT_AUTOREFERER);
Expand Down

1 comment on commit 7bdd2b5

@vldevel
Copy link
Contributor

@vldevel vldevel commented on 7bdd2b5 Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You speak about curl >= 7 in the comment, but you test for LIBCURL_VERSION_MAJOR > 7 in the code... Which one is correct ?

FYI, I had, in the Cool VL Viewer, curl_easy_setopt(mCurlHandle, CURLOPT_ENCODING, ""); only for curl 7.59 and older, and this option was not used at all for curl 7.60 and newer (but I only tested up to v7.64 with my viewer).

Note also that a 'grep -r getCurlTemplateHandle indra/*' shows that getCurlTemplateHandle() is used only by createEasyHandle() in httpcommon.cpp, but another grep with createEasyHandle reveals that it is not used anywhere in the viewer: these two functions could therefore be entirely removed...

Please sign in to comment.