Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved QUrl supports Post?

    General and Desktop
    2
    3
    608
    Loading More Posts
    • 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.
    • D
      Dev1337 last edited by Dev1337

      Hi together,

      i am using C++ to send some data to the server but got a problem now.
      QUrlQuery is sending the data in the url like "www.bla.bla&id=1&etc" with the GET Method.

      But i need to send the data with the POST Method because im sending more than 20k chars.

      Right now it looks like this

      QUrlQuery query;
      query.addQueryItem(QStringLiteral("data1"), data1);
      query.addQueryItem(QStringLiteral("data2"), data2);

      QUrl requestUrl(m_url);
      requestUrl.setQuery(query);
      QNetworkRequest request(requestUrl);
      request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
      request.setPriority(QNetworkRequest::HighPriority);
      QNetworkReply *reply = manager->get(request);
      connect(reply, &QNetworkReply::finished, this, [this, reply] {
      QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> replyPtr(reply);
      m_data = replyPtr->readAll();
      qDebug() << m_data;
      });

      So the problem is, Get is limited and i get an error from the server.

      <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<html><head>\n<title>414 Request-URI Too Long</title>\n</head><body>\n<h1>Request-URI Too Long</h1>\n<p>The requested URL's length exceeds the capacity\nlimit for this server.<br />\n</p>\n<hr>\n<address>Apache Server at default Port 80</address>\n</body></html>

      How can i use the Post Method?

      thx 4 help

      JKSH 1 Reply Last reply Reply Quote 0
      • JKSH
        JKSH Moderators @Dev1337 last edited by

        Hi,

        @Dev1337 said:

        How can i use the Post Method?

        Call QNetworkAccessManager::post() instead of QNetworkAccessManager::get().

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply Reply Quote 1
        • D
          Dev1337 last edited by Dev1337

          Thx worked.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post