Qt 5.8 http2

  • Hello,

    I tried enabling http2 in my project using Qt 5.8 but when i actually execute a request the server still says it's still http 1.1.
    Here is the test project i made.

    #include <QGuiApplication>
    #include <QNetworkRequest>
    #include <QNetworkReply>
    #include <QNetworkAccessManager>
    #include <QDebug>
    #include <QEventLoop>
    int main(int argc, char *argv[])
       QCoreApplication app(argc, argv);
       QNetworkRequest req(QUrl("https://nghttp2.org/httpbin/headers"));
       req.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true));
       QNetworkAccessManager manager;
       QNetworkReply* reply = manager.get(req);
       QEventLoop eventLoop;
       QObject::connect(reply, SIGNAL(finished()), &eventLoop, SLOT(quit()));
       QList<QByteArray> reply_headers = reply->rawHeaderList();
       foreach(QByteArray head, reply_headers) {
           qDebug() << head << ":" << reply->rawHeader(head);
       qDebug().noquote() << reply->readAll();
       return app.exec();

    And here is the output i get (still http 1.1)

    "Date" : "Tue, 21 Feb 2017 10:50:35 GMT"
    "Content-Type" : "application/json"
    "Content-Length" : "182"
    "Access-Control-Allow-Origin" : "*"
    "Access-Control-Allow-Credentials" : "true"
    "X-Backend-Header-Rtt" : "0.002562"
    "Strict-Transport-Security" : "max-age=31536000"
    "Connection" : "close"
    "Server" : "nghttpx nghttp2/1.20.0-DEV"
    "Via" : "1.1 nghttpx"
    "x-frame-options" : "SAMEORIGIN"
    "x-xss-protection" : "1; mode=block"
    "x-content-type-options" : "nosniff"
      "headers": {
        "Accept-Encoding": "gzip, deflate",
        "Accept-Language": "en-US,*",
        "Host": "nghttp2.org",
        "User-Agent": "Mozilla/5.0",
        "Via": "1.1 nghttpx"

    What am i doing wrong? Is there another flag i need to enable to make it work?

    Thank you.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.