#include <QCoreApplication>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QDateTime>
#include <QObject>
#include <QDebug>

void debug(int step)
{
    static QDateTime t = QDateTime::currentDateTime();
    qDebug() << step << QString::number(t.msecsTo(QDateTime::currentDateTime()) / 1000.0f, 'f', 3).toUtf8().constData() << "sec";
}

class Test : public QObject
{
    Q_OBJECT
public:
    explicit Test(QObject *parent = 0) : QObject(parent)
    {
        debug(1);
        QNetworkRequest request;

        debug(2);
        request.setUrl(QUrl("http://google.com"));

        debug(3);
        r = m.get(request);

        debug(4);
        connect (r, SIGNAL(finished()), this, SLOT(downloaded()));
    }

private slots:
    void downloaded()
    {
        debug(5);
        qDebug() << QString("downloaded %1 bytes").arg(r->readAll().size()).toUtf8().constData();
        qApp->exit(0);
    }

private:
    QNetworkAccessManager m;
    QNetworkReply *r;
};


int main(int argc, char *argv[])
{
    debug(10);
    QCoreApplication a(argc, argv);

    debug(20);
    Test t1;

    debug(30);
    Test t2;

    debug(40);
    return a.exec();

    debug(50);
}

#include "release/main.moc"
