Note that there are some explanatory texts on larger screens.

plurals
  1. POwhat is the best library to send http request for desktop applications
    primarykey
    data
    text
    <p>My application is running in Windows and I have to send some requests to the server. I am currently using libcurl.</p> <p>However there is a limitation when proxy server with authentication is involved before the request sent out to the server.</p> <p>I explored the options in libcurl but i could not able to make it work. If i hardcode the username / password it works. But I do not want to get the user name and password by my application; I would prefer that libcurl can requests these at the start of a transfer.</p> <p>Is there a different library i can use like winhttp or libcurl is the best one to use?</p> <p>Below are the curl settings done before making the request</p> <pre><code>curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_URL, urlString.data()); curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, receiveDataCallback); curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, &amp;curlPerformStorage); curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_USERAGENT, "libcurl-agent/1.0"); curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_FOLLOWLOCATION, 1); if(NULL != GetWindowsProxyConfig().lpszProxy){ LPWSTR wStr = GetWindowsProxyConfig().lpszProxy; char* buffer = new char[100]; wcstombs(buffer, wStr, 100) ; curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_PROXY, "&lt;proxy_name&gt;"); curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_PROXYPORT, &lt;number&gt;); curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_HTTPAUTH, CURLAUTH_NONE); curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); } else { curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_PROXY, "&lt;proxy_name&gt;"); curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_PROXYPORT, &lt;number&gt;); curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_HTTPAUTH, CURLAUTH_NTLM); curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_PROXYAUTH, CURLAUTH_NTLM); } curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_USE_SSL, CURLUSESSL_ALL); curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_SSL_VERIFYPEER, 1); curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_SSL_VERIFYHOST, 2); if(proxyStr.length() &gt; 0){ curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_HTTPPROXYTUNNEL, 1L); } curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_FAILONERROR, 1); curlResultCode= curl_easy_setopt ( curlHandle, CURLOPT_ERRORBUFFER, errorbuffer ); int nConnectionTimeout = curlPerformStorage.GetConnectionTimeOut(); if (nConnectionTimeout &gt; 0) { curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_CONNECTTIMEOUT, nConnectionTimeout); } int nTransferTimeout = curlPerformStorage.GetTransferTimeOut(); if (nTransferTimeout &gt; 0) { curlResultCode=curl_easy_setopt(curlHandle, CURLOPT_TIMEOUT, nTransferTimeout); } curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_PROGRESSFUNCTION , ProgressCallback); if (curlResultCode == CURLE_OK) { curlResultCode = curl_easy_setopt(curlHandle, CURLOPT_NOPROGRESS, FALSE); curlResultCode= curl_easy_setopt(curlHandle, CURLOPT_PROGRESSDATA , &amp;curlPerformStorage); } curlResultCode = curl_easy_perform(curlHandle); if (curlResultCode != CURLE_OK) { } else { } curl_easy_reset(curlHandle); return curlResultCode; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload