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. [Solved] QNAM : check if range header supported
Forum Updated to NodeBB v4.3 + New Features

[Solved] QNAM : check if range header supported

Scheduled Pinned Locked Moved General and Desktop
13 Posts 3 Posters 3.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.
  • Chris KawaC Offline
    Chris KawaC Offline
    Chris Kawa
    Lifetime Qt Champion
    wrote on last edited by
    #2

    You can't know anything about the server before contacting it. The only way to check if it supports partial content is to ask for some, ideally a small part of small file not to wait and waste bandwidth if it sends the whole thing. If the server supports partial content it will respond with 206 status code instead of the usual 200.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #3

      Hi,

      Try with "QNetworkAccessManager::​head":http://doc.qt.io/qt-5/qnetworkaccessmanager.html#head. Then in reply you can check for the particular header.

      157

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ashishbansal
        wrote on last edited by
        #4

        [quote author="Chris Kawa" date="1419768795"]You can't know anything about the server before contacting it. The only way to check if it supports partial content is to ask for some, ideally a small part of small file not to wait and waste bandwidth if it sends the whole thing. If the server supports partial content it will respond with 206 status code instead of the usual 200.[/quote]

        Okay. Thanks!
        How can I check those status code and I have read somewhere some servers does not sends 206 but supports that header. Is there any way to tackle that??

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

          [quote author="p3c0" date="1419768801"]Hi,

          Try with "QNetworkAccessManager::​head":http://doc.qt.io/qt-5/qnetworkaccessmanager.html#head. Then in reply you can check for the particular header.[/quote]

          Hey I just tried that but the reply is returning empty rawHeaderList.

          1 Reply Last reply
          0
          • Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by
            #6

            bq. How can I check those status code

            @
            //reply is the QNetworkReply*
            reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
            @

            As for the broken servers you'd have to compare sizes. Request for e.g. 1 byte of a larger file and see if you get the byte or the whole thing in reply.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              ashishbansal
              wrote on last edited by
              #7

              [quote author="Chris Kawa" date="1419770030"]bq. How can I check those status code

              @
              //reply is the QNetworkReply*
              reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
              @

              As for the broken servers you'd have to compare sizes. Request for e.g. 1 byte of a larger file and see if you get the byte or the whole thing in reply.[/quote]

              Okay, Cool!
              Thanks again!

              1 Reply Last reply
              0
              • p3c0P Offline
                p3c0P Offline
                p3c0
                Moderators
                wrote on last edited by
                #8

                @ashishbansal may we know which URL are you trying ?

                157

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  ashishbansal
                  wrote on last edited by
                  #9

                  [quote author="p3c0" date="1419771749"]ashishbansal may we know which URL are you trying ?[/quote]

                  I have tried with these two links : http://ashish-bansal.in/css/loader.css and
                  https://s.basketbuild.com/dl/devs?dl=pawitp/i9082_cm12.0/cm-12-20141220-UNOFFICIAL-i9082.zip

                  And like this.

                  @QNetworkReply *headReply = qnam->head(*req);
                  qDebug() << headReply->rawHeaderList();@

                  And I am getting this as output.
                  @()
                  () @

                  1 Reply Last reply
                  0
                  • Chris KawaC Offline
                    Chris KawaC Offline
                    Chris Kawa
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    You can't check any contents of the reply before it arrives. Neither the method I gave nor that one will work this way. You need to connect to the finished() signal of the reply and check then.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      ashishbansal
                      wrote on last edited by
                      #11

                      [quote author="Chris Kawa" date="1419772556"]You can't check the contents of the reply before it arrives. Neither the method I gave nor that one will work this way. You need to connect to the finished() signal of the reply and check then.[/quote]

                      Oh that's why that method didn't worked. While testing your method, I made the changes in slot connected to QNetworkReply::downloadProgress . That's why it worked.

                      1 Reply Last reply
                      0
                      • p3c0P Offline
                        p3c0P Offline
                        p3c0
                        Moderators
                        wrote on last edited by
                        #12

                        QNetworkAccessManager::​head works as expected for those URL's.

                        157

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          ashishbansal
                          wrote on last edited by
                          #13

                          [quote author="p3c0" date="1419773224"]QNetworkAccessManager::​head works as expected for those URL's.[/quote]

                          Yeah I realized that silly mistake.
                          Thanks!

                          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