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. "Not supported" reply while using QNetworkAccessManager Qt5.11.
QtWS25 Last Chance

"Not supported" reply while using QNetworkAccessManager Qt5.11.

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 301 Views
  • 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.
  • S Offline
    S Offline
    Sandip Rakhasiya
    wrote on last edited by
    #1

    Hello,

    Previously I am using Qt4.8 and with that, QNetworkAccessManager GET/POST request with bearer working correctly.
    Now I am migrating my code to Qt5.11. But when I am using QNetworkAccessManager, the Application is crashing and on a terminal log, "Not supported" message is coming.

    Even I have tried simple POST example from Qt5 but same result.

    Please help me for the same. Thanks in Advance.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to the forum

      A good start would be to use the debugger and find out what line it's crashing in.
      Many years between 4.8 and 5.11 so its very hard to guess at with no code or any other information.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sandip Rakhasiya
        wrote on last edited by Sandip Rakhasiya
        #3

        Hello @mrjj ,

        At last, I have commented whole code and just defined QNetworkAccessManager but the definition itself crashed the Whole application and "Not supported" logs on the Linux console.

        I have tried with debug also and result is same.
        Anything with Qt5 configuration of QNetworkAccessmanager?

        mrjjM 1 Reply Last reply
        0
        • S Sandip Rakhasiya

          Hello @mrjj ,

          At last, I have commented whole code and just defined QNetworkAccessManager but the definition itself crashed the Whole application and "Not supported" logs on the Linux console.

          I have tried with debug also and result is same.
          Anything with Qt5 configuration of QNetworkAccessmanager?

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi
          just defining QNetworkAccessManager should not crash app.

          I cannot find out what "Not supported" should come from.

          so example like

          // https://github.com/KubaO/stackoverflown/tree/master/questions/html-get-24965972
          #include <QtNetwork>
          #include <functional>
          
          void htmlGet(const QUrl &url, const std::function<void(const QString&)> &fun) {
             QScopedPointer<QNetworkAccessManager> manager(new QNetworkAccessManager);
             QNetworkReply *response = manager->get(QNetworkRequest(QUrl(url)));
             QObject::connect(response, &QNetworkReply::finished, [response, fun]{
                response->deleteLater();
                response->manager()->deleteLater();
                if (response->error() != QNetworkReply::NoError) return;
                auto const contentType =
                      response->header(QNetworkRequest::ContentTypeHeader).toString();
                static QRegularExpression re("charset=([!-~]+)");
                auto const match = re.match(contentType);
                if (!match.hasMatch() || 0 != match.captured(1).compare("utf-8", Qt::CaseInsensitive)) {
                   qWarning() << "Content charsets other than utf-8 are not implemented yet:" << contentType;
                   return;
                }
                auto const html = QString::fromUtf8(response->readAll());
                fun(html); // do something with the data
             }) && manager.take();
          }
          
          int main(int argc, char *argv[])
          {
             QCoreApplication app(argc, argv);
             htmlGet({"http://www.google.com"}, [](const QString &body){ qDebug() << body; qApp->quit(); });
             return app.exec();
          }
          

          also crashes ?

          1 Reply Last reply
          0
          • J Offline
            J Offline
            James A
            wrote on last edited by
            #5

            Hai All,

            Even I am facing similar crash issue in my embedded Linux device , I have developed a QML application , and declared QNetworkAccessManager in a separate thread and QML GUI in main thread. The complete application is getting crashed after some time.
            The crash is not happening during debugging from QT creator , it appears only when running the application has a standalone. I am using Qt 5.11.3.

            Regards,
            James A

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              Check all your pointers.

              Are you sure you are not triggering a double deletion ?

              Since you have multiple threads ensure that you are not accessing common data without proper protection in place.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1

              • Login

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