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. QNetworkAccessManager: put request uncomplete on localhost

QNetworkAccessManager: put request uncomplete on localhost

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 5.1k 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.
  • B Offline
    B Offline
    bernd71
    wrote on last edited by
    #1

    Hi

    For a REST client/server solution I try to usethe QNetworkAccessManager::put() method for HTTP PUT requests in the client app. The server receives only the HTTP header but no content data (ca. 2500 bytes) if both runs on the same machine (localhost). Content length is correct in the received HTTP header. The server app uses the QTcpServer class. It receives the header twice (after time out for content) from the client but no content data. I got no error value and GET requests works fine.
    With two different machines the put request works like expected. With a Java REST test application put request works fine on localhost.
    This occurs on Windows and Linux.

    Any ideas?

    Thanks
    Bernd

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      How are you invoking QNetworkAccessManager::put exactly? Can you -attach- pastebin/upload somewhere a complete pcap log?

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bernd71
        wrote on last edited by
        #3

        The code:

        @QNetworkRequest request;
        request.setUrl(url);
        if(!szUserAgent.isEmpty())
        {
        request.setRawHeader("User-Agent", szUserAgent.toAscii());
        }
        if(!szAcceptEncoding.isEmpty())
        {
        request.setRawHeader("Accept-Encoding", szAcceptEncoding.toAscii());
        }
        if(!szContentType.isEmpty())
        {
        request.setHeader(request.ContentTypeHeader, szContentType);

        m_pReply = m_manager->put(request, baContent);
        if(m_pReply != 0L)
        {
        connect(m_pReply, SIGNAL(error ( QNetworkReply::NetworkError)), this, SLOT( PutRequestError(QNetworkReply::NetworkError)));
        connect(m_pReply, SIGNAL( uploadProgress ( qint64 , qint64)), this, SLOT( PutRequestUploadProgress ( qint64 , qint64)));
        QNetworkReply::NetworkError error = m_pReply->error();
        if(error == QNetworkReply::NoError)
        {
        ...
        }@

        The baContent is a QByteArray with XML content.

        Is it possible to log localhost network traffic? I thought it is only possible with real network traffic. But I have only exerience with Wireshark on Windows. I will try to get a log.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #4

          It's possible to capture local traffic.

          BTW, what's at line 23? Why are you checking for errors even before than returning to the event loop?

          Software Engineer
          KDAB (UK) Ltd., a KDAB Group company

          1 Reply Last reply
          0
          • B Offline
            B Offline
            bernd71
            wrote on last edited by
            #5

            There is nothing only a debug messages and set a return value for the method. I added this after I saw that it doesn't work. I thought that maybe I get an error right after the call that helps me.
            Could the live time of the content QByteArray be a problem?

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              No, the byte array will be copied (using implicit sharing) to the request object, so doubt that is it.

              1 Reply Last reply
              0
              • B Offline
                B Offline
                bernd71
                wrote on last edited by
                #7

                I logged the request and it seems to be ok. Both header and content are present in one packet. I will take a closer look to the server code.

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  bernd71
                  wrote on last edited by
                  #8

                  I solved the problem. It was a problem in the server code that under some circumstances the put content was not received or better say flushed.

                  Thanks for your help!

                  Bernd

                  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