Skip to content

Latest commit

 

History

History
29 lines (24 loc) · 768 Bytes

README.md

File metadata and controls

29 lines (24 loc) · 768 Bytes

QtCurl

A simple wrapper around libcurl's easy interface. Allows you to send requests via curl using QNetworkRequest, and receive the response as a QNetworkReply.

#include <qcurl.h>
#include <QDebug>

int main(int argc, const char** argv)
{
  QCurl curl;
  QNetworkRequest request;
  QNetworkReply* reply;

  request.setUrl(QUrl("https://duckduckgo.com"));
  reply = curl.send(request);
  if (reply)
  {
    qDebug() << "Received response:"
      << "status=" << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toUInt()
      << "body=" << reply->readAll();
    return 0;
  }
  else
    qDebug() << "QCurl could not send the request";
  return -1;
}