| 144 | } |
| 145 | |
| 146 | bool CHttpRequest::ConfigureHandle(void *pHandle) |
| 147 | { |
| 148 | CURL *pH = (CURL *)pHandle; |
| 149 | if(!BeforeInit()) |
| 150 | { |
| 151 | return false; |
| 152 | } |
| 153 | |
| 154 | if(g_Config.m_DbgCurl) |
| 155 | { |
| 156 | curl_easy_setopt(pH, CURLOPT_VERBOSE, 1L); |
| 157 | curl_easy_setopt(pH, CURLOPT_DEBUGFUNCTION, CurlDebug); |
| 158 | } |
| 159 | long Protocols = CURLPROTO_HTTPS; |
| 160 | if(g_Config.m_HttpAllowInsecure) |
| 161 | { |
| 162 | Protocols |= CURLPROTO_HTTP; |
| 163 | } |
| 164 | |
| 165 | curl_easy_setopt(pH, CURLOPT_ERRORBUFFER, m_aErr); |
| 166 | |
| 167 | curl_easy_setopt(pH, CURLOPT_CONNECTTIMEOUT_MS, m_Timeout.m_ConnectTimeoutMs); |
| 168 | curl_easy_setopt(pH, CURLOPT_TIMEOUT_MS, m_Timeout.m_TimeoutMs); |
| 169 | curl_easy_setopt(pH, CURLOPT_LOW_SPEED_LIMIT, m_Timeout.m_LowSpeedLimit); |
| 170 | curl_easy_setopt(pH, CURLOPT_LOW_SPEED_TIME, m_Timeout.m_LowSpeedTime); |
| 171 | if(m_MaxResponseSize >= 0) |
| 172 | { |
| 173 | curl_easy_setopt(pH, CURLOPT_MAXFILESIZE_LARGE, (curl_off_t)m_MaxResponseSize); |
| 174 | } |
| 175 | if(m_IfModifiedSince >= 0) |
| 176 | { |
| 177 | curl_easy_setopt(pH, CURLOPT_TIMEVALUE_LARGE, (curl_off_t)m_IfModifiedSince); |
| 178 | curl_easy_setopt(pH, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE); |
| 179 | } |
| 180 | |
| 181 | // ‘CURLOPT_PROTOCOLS’ is deprecated: since 7.85.0. Use CURLOPT_PROTOCOLS_STR |
| 182 | // Wait until all platforms have 7.85.0 |
| 183 | #ifdef __GNUC__ |
| 184 | #pragma GCC diagnostic push |
| 185 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
| 186 | #endif |
| 187 | curl_easy_setopt(pH, CURLOPT_PROTOCOLS, Protocols); |
| 188 | #ifdef __GNUC__ |
| 189 | #pragma GCC diagnostic pop |
| 190 | #endif |
| 191 | curl_easy_setopt(pH, CURLOPT_FOLLOWLOCATION, 1L); |
| 192 | curl_easy_setopt(pH, CURLOPT_MAXREDIRS, 4L); |
| 193 | if(m_FailOnErrorStatus) |
| 194 | { |
| 195 | curl_easy_setopt(pH, CURLOPT_FAILONERROR, 1L); |
| 196 | } |
| 197 | curl_easy_setopt(pH, CURLOPT_URL, m_aUrl); |
| 198 | curl_easy_setopt(pH, CURLOPT_NOSIGNAL, 1L); |
| 199 | curl_easy_setopt(pH, CURLOPT_USERAGENT, GAME_NAME " " GAME_RELEASE_VERSION " (" CONF_PLATFORM_STRING "; " CONF_ARCH_STRING ")"); |
| 200 | curl_easy_setopt(pH, CURLOPT_ACCEPT_ENCODING, ""); // Use any compression algorithm supported by libcurl. |
| 201 | |
| 202 | curl_easy_setopt(pH, CURLOPT_HEADERDATA, this); |
| 203 | curl_easy_setopt(pH, CURLOPT_HEADERFUNCTION, HeaderCallback); |