Asked 7 years ago
31 Dec 2016
Views 1175

posted

HTTP REQUEST in c++

how to make HTTP REQUEST in c++ ? trying to call web api for checking latest install of software and inshort on calling HTTP REQUEST it give me some info and need to use it in c++

so how one can make HTTP call to server in c++ ?
shyam

shyam
answered Nov 30 '-1 00:00

C++ and GUI come together in QT . one can use QNetworkRequest for HTTP request in QT.


#include <QtNetwork>
#include <QUrl>
..
QUrl url = QUrl::fromEncoded("http://www.google.com/jsapi");
 QNetworkRequest(url)
..
..



ravi

ravi
answered Nov 30 '-1 00:00

i have this with libcurl

easy = curl_easy_init();
  if(easy)
  {
    exit(2);
  }
  curl_easy_setopt(easy, CURLOPT_URL, url);
  curl_easy_cleanup(easy);
 


i used libcurl-easy , curl_easy_init() will return an easy handle
and curl_easy_setopt used to set option . and CURLOPT_URL is need to set to communicate with web api . curl_easy_cleanup() will cleanup seesion of the request.

Post Answer