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. How to know if QNetworkReply has a body?
Forum Updated to NodeBB v4.3 + New Features

How to know if QNetworkReply has a body?

Scheduled Pinned Locked Moved Solved General and Desktop
qnetworkreply
6 Posts 2 Posters 2.2k 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.
  • F Offline
    F Offline
    FujuMazzr
    wrote on last edited by
    #1

    I'm wondering, how to know if QNetworkReply has a body? I tried find and I couldn't find any method like ->hasBody or something like that.

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

      Hi and welcome to devnet,

      There's nothing like that. You have to parse the content of the reply that you received.

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

      F 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        There's nothing like that. You have to parse the content of the reply that you received.

        F Offline
        F Offline
        FujuMazzr
        wrote on last edited by
        #3

        @SGaist With parse you mean, put the reply->readAll() in a QString and check if it is empty?

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

          Yes, but checking for empty depends on what request you did. You can have a valid empty answer i.e. status code 200 for an operation that doesn't answer anything particular.

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

          F 1 Reply Last reply
          0
          • SGaistS SGaist

            Yes, but checking for empty depends on what request you did. You can have a valid empty answer i.e. status code 200 for an operation that doesn't answer anything particular.

            F Offline
            F Offline
            FujuMazzr
            wrote on last edited by
            #5

            @SGaist Yes, I know, I'm making a few tests with a local server and that is exactly the idea, to check if the body is empty, not the status code or anything else, only if the body is empty.

            I thought that Qt would have a method or something like hasBody, but I can live with that.

            Thank you.

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

              You're welcome !

              Since the point has been clarified, please mark the thread as solved using the "Topic Tool" button so other forum users may know a solution has been found :)

              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