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. QUrl supports Post?
Forum Updated to NodeBB v4.3 + New Features

QUrl supports Post?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 768 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.
  • D Offline
    D Offline
    Dev1337
    wrote on last edited by Dev1337
    #1

    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

    JKSHJ 1 Reply Last reply
    0
    • D 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

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      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
      1
      • D Offline
        D Offline
        Dev1337
        wrote on last edited by Dev1337
        #3

        Thx worked.

        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