-1

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++.

  • Standard C++ doesn't have anything like that. There are libraries and frameworks which adds similar classes, structures or functionality, please spend some time with your favorite search engine to find some. – Some programmer dude Jul 12 '20 at 08:43
  • 3
    Does this answer your question? [How do you make a HTTP request with C++?](https://stackoverflow.com/questions/1011339/how-do-you-make-a-http-request-with-c) or [C++ interface version of HttpWebRequest and HttpWebResponse](https://stackoverflow.com/questions/1907131/c-interface-version-of-httpwebrequest-and-httpwebresponse). – brc-dd Jul 12 '20 at 09:38

1 Answers1

0

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/