में देशी सी/सी ++ के लिए उच्च स्तरीय HTTP क्लाइंट लाइब्रेरी Win32 में देशी सी/सी ++ के लिए कोई "उच्च स्तरीय" HTTP लाइब्रेरी नहीं है या क्या मैं केवल गलत स्थानों को देख रहा हूं?Win32
"उच्च स्तरीय" से मेरा मतलब एक एपीआई है जो मुझे सीई ++ में HTTP वेब अनुरोध/प्रतिक्रियाओं को "उसी के बारे में" अबास्ट्रक्शन स्तर के साथ .NET फ्रेमवर्क के रूप में करने देता है (लेकिन ध्यान दें कि C++/CLI का उपयोग करना एक विकल्प नहीं है मेरे लिए)।
.NET का उपयोग किए बिना Win32 में C/C++ में ऐसा कुछ कैसे करें (कोड की उसी मात्रा के साथ) कैसे करें? एक संदर्भ के रूप में, मैं यह दिखाने के लिए एक कोड नमूना शामिल करता हूं कि मैं इसे सी # में कैसे करूं।
byte[] fileBytes = null;
bool successfulDownload = false;
using (WebClient client = new WebClient())
{
WebProxy proxy = WebProxy.GetDefaultProxy();
client.Proxy = proxy;
tryAgain:
try
{
fileBytes = client.DownloadData(fileUrl);
successfulDownload = true;
}
catch (WebException wEx)
{
if (wEx.Response != null && wEx.Response is HttpWebResponse)
{
string username = null, password = null;
bool userCanceled = false;
HttpStatusCode statusCode = ((HttpWebResponse)wEx.Response).StatusCode;
switch (statusCode)
{
case HttpStatusCode.ProxyAuthenticationRequired:
// This is just a convenience function defined elsewhere
GetAuthenticationCredentials(fileUrl, true,
out username, out password, out userCanceled);
if (!userCanceled)
{
client.Proxy.Credentials = new NetworkCredential(username, password);
goto tryAgain;
}
break;
case HttpStatusCode.Unauthorized:
// This is just a convenience function defined elsewhere
GetAuthenticationCredentials(fileUrl, false,
out username, out password, out userCanceled);
if (!userCanceled)
{
client.Credentials = new NetworkCredential(username, password);
goto tryAgain;
}
break;
}
}
}
}
डुप्लिकेट: http://stackoverflow.com/questions/822581/what-c-library-for-http-client –