Skip to content

Instantly share code, notes, and snippets.

@v-kolesnikov
Created May 23, 2015 15:52
Show Gist options
  • Save v-kolesnikov/cd6a8e93d62be5b2e7be to your computer and use it in GitHub Desktop.
Save v-kolesnikov/cd6a8e93d62be5b2e7be to your computer and use it in GitHub Desktop.
SimpleRequest
#include <QCoreApplication>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QUrl>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QUrl url("http://surfer.96.lt/out.php");
QNetworkAccessManager *nam = new QNetworkAccessManager;
QNetworkRequest request(url);
QNetworkReply *reply = nam->get(request);
QObject::connect(reply, &QNetworkReply::finished, [reply]() {
qDebug() << "\nReply:";
for (auto header : reply->rawHeaderPairs()) {
qDebug() << header.first << ":" << header.second;
}
qDebug() << reply->readAll();
reply->deleteLater();
qApp->quit();
});
return a.exec();
}
#-------------------------------------------------
#
# Project created by QtCreator 2015-05-23T18:26:20
#
#-------------------------------------------------
QT += core network
QT -= gui
CONFIG += c++11
TARGET = SimpleRequest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment