简体   繁体   中英

How to use HttpWebRequest in c++ compare c#?

I want to understand how to use httpwebreuqest in c++. For c# it is easy -

string html = string.Empty;
string url = @"https://api.stackexchange.com/2.2/answers?order=desc&sort=activity&site=stackoverflow";

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    request.AutomaticDecompression = DecompressionMethods.GZip;
    
    using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
    using (Stream stream = response.GetResponseStream())
    using (StreamReader reader = new StreamReader(stream))
    {
        html = reader.ReadToEnd();
    }
    
    Console.WriteLine(html);

But i dont know how to start for c++.

You need to use CPPRest SDK / Casablanca in C++. I could find some examples here - http://ramvellanki.github.io/blog/2016/05/15/working-with-casablanca-cpprestsdk/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM