Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt 5.8 http2
Forum Updated to NodeBB v4.3 + New Features

Qt 5.8 http2

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pavel25
    wrote on last edited by
    #1

    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()));
       eventLoop.exec();
    
       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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved