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. QNetworkReply reply 301 issue
Qt 6.11 is out! See what's new in the release blog

QNetworkReply reply 301 issue

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 4 Posters 6.4k 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.
  • V Offline
    V Offline
    victor wang
    wrote on last edited by victor wang
    #1

    Hi, i'm using Qt5.5 on my computer.
    When i clicked the button then will do the request.
    This is my code here

    It will do the SLOT thing.
    Get into replyFinished(), code is here

    When i print the qDebug out, it shows 301.
    I went to search the information and i saw one of the information here(please search 301)

    How can i fix this one?

    jsulmJ 1 Reply Last reply
    0
    • V victor wang

      Hi, i'm using Qt5.5 on my computer.
      When i clicked the button then will do the request.
      This is my code here

      It will do the SLOT thing.
      Get into replyFinished(), code is here

      When i print the qDebug out, it shows 301.
      I went to search the information and i saw one of the information here(please search 301)

      How can i fix this one?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @victor-wang
      There is nothing to fix.
      See here: https://en.wikipedia.org/wiki/HTTP_301
      It means the URL you're trying to access has moved.
      The new URL should be in the reply.
      Just try another URL like https://www.qt.io/developers

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      V 2 Replies Last reply
      1
      • Paul ColbyP Offline
        Paul ColbyP Offline
        Paul Colby
        wrote on last edited by
        #3

        Also consider using QNetworkRequest::FollowRedirectsAttribute, if that suits your need :)

        Cheers.

        1 Reply Last reply
        2
        • jsulmJ jsulm

          @victor-wang
          There is nothing to fix.
          See here: https://en.wikipedia.org/wiki/HTTP_301
          It means the URL you're trying to access has moved.
          The new URL should be in the reply.
          Just try another URL like https://www.qt.io/developers

          V Offline
          V Offline
          victor wang
          wrote on last edited by
          #4

          @jsulm
          Did you mean i have to change the website like this ?

          manager->get(QNetworkRequest(QUrl("https://www.qt.io/developers")));
          
          jsulmJ 1 Reply Last reply
          0
          • V victor wang

            @jsulm
            Did you mean i have to change the website like this ?

            manager->get(QNetworkRequest(QUrl("https://www.qt.io/developers")));
            
            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @victor-wang You can, or do what @Paul-Colby suggested.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • jsulmJ jsulm

              @victor-wang
              There is nothing to fix.
              See here: https://en.wikipedia.org/wiki/HTTP_301
              It means the URL you're trying to access has moved.
              The new URL should be in the reply.
              Just try another URL like https://www.qt.io/developers

              V Offline
              V Offline
              victor wang
              wrote on last edited by
              #6

              @jsulm
              It's not wok.
              It still will print 301 out.
              @Paul-Colby
              I will try it.

              jsulmJ 1 Reply Last reply
              0
              • V victor wang

                @jsulm
                It's not wok.
                It still will print 301 out.
                @Paul-Colby
                I will try it.

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @victor-wang It should work. Did you rebuild?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                V 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @victor-wang It should work. Did you rebuild?

                  V Offline
                  V Offline
                  victor wang
                  wrote on last edited by victor wang
                  #8

                  @jsulm
                  Yes, i had rebuild it.

                  But QNetworkReply::NetworkError still print 301 out to me.

                  The information said if you receive 301 it means "the Network Access API cannot honor the request because the protocol is not known" .

                  @Paul-Colby
                  Why i can't find FollowRedirectsAttribute on my Qt?

                  jsulmJ 1 Reply Last reply
                  0
                  • V victor wang

                    @jsulm
                    Yes, i had rebuild it.

                    But QNetworkReply::NetworkError still print 301 out to me.

                    The information said if you receive 301 it means "the Network Access API cannot honor the request because the protocol is not known" .

                    @Paul-Colby
                    Why i can't find FollowRedirectsAttribute on my Qt?

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @victor-wang FollowRedirectsAttribute was introduced in Qt 5.6. Which Qt version do you use?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    V 1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @victor-wang FollowRedirectsAttribute was introduced in Qt 5.6. Which Qt version do you use?

                      V Offline
                      V Offline
                      victor wang
                      wrote on last edited by
                      #10

                      @jsulm
                      Yes, i had rebuild it.

                      But QNetworkReply::NetworkError still print 301 out to me.

                      The information said if you receive 301 it means "the Network Access API cannot honor the request because the protocol is not known" .

                      I'm using Qt5.5 that's why i can't using it.

                      jsulmJ 2 Replies Last reply
                      0
                      • V victor wang

                        @jsulm
                        Yes, i had rebuild it.

                        But QNetworkReply::NetworkError still print 301 out to me.

                        The information said if you receive 301 it means "the Network Access API cannot honor the request because the protocol is not known" .

                        I'm using Qt5.5 that's why i can't using it.

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @victor-wang Please read the link I provided. 301 means:
                        "The HTTP response status code 301 Moved Permanently is used for permanent URL redirection" - it is not related to protocol.

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        H 1 Reply Last reply
                        0
                        • V victor wang

                          @jsulm
                          Yes, i had rebuild it.

                          But QNetworkReply::NetworkError still print 301 out to me.

                          The information said if you receive 301 it means "the Network Access API cannot honor the request because the protocol is not known" .

                          I'm using Qt5.5 that's why i can't using it.

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @victor-wang You will need to handle redirections (301) by yourself: the new URL should be in the response (see the link I posted):

                          HTTP/1.1 301 Moved Permanently
                          Location: http://www.example.org/index.asp
                          

                          "Location" contains the new URL.

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          V 1 Reply Last reply
                          2
                          • jsulmJ jsulm

                            @victor-wang You will need to handle redirections (301) by yourself: the new URL should be in the response (see the link I posted):

                            HTTP/1.1 301 Moved Permanently
                            Location: http://www.example.org/index.asp
                            

                            "Location" contains the new URL.

                            V Offline
                            V Offline
                            victor wang
                            wrote on last edited by
                            #13

                            @jsulm
                            I'm using "http://www.example.org/index.asp"
                            But i get the error 404.
                            Why is that happened?

                            jsulmJ 1 Reply Last reply
                            0
                            • V victor wang

                              @jsulm
                              I'm using "http://www.example.org/index.asp"
                              But i get the error 404.
                              Why is that happened?

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              @victor-wang Can you access this URL using a web browser on the same machine?
                              Did you enter the URL correctly in your code?

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              V 1 Reply Last reply
                              0
                              • jsulmJ jsulm

                                @victor-wang Can you access this URL using a web browser on the same machine?
                                Did you enter the URL correctly in your code?

                                V Offline
                                V Offline
                                victor wang
                                wrote on last edited by victor wang
                                #15

                                @jsulm
                                I can't ping anything on "Location".
                                There is an error here

                                And i"m sure that i had write the write URL in my code.
                                But i will get the error 404.

                                Besides, i've try the other URL which is the test URL gave from my company.
                                And i got the error 0!

                                What should i do ?

                                jsulmJ 1 Reply Last reply
                                0
                                • V victor wang

                                  @jsulm
                                  I can't ping anything on "Location".
                                  There is an error here

                                  And i"m sure that i had write the write URL in my code.
                                  But i will get the error 404.

                                  Besides, i've try the other URL which is the test URL gave from my company.
                                  And i got the error 0!

                                  What should i do ?

                                  jsulmJ Offline
                                  jsulmJ Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  @victor-wang Interesting: I can access that URL in a browser but ping does not work.
                                  Maybe there is something with out network? Do you have a proxy? Firewall?

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  V 1 Reply Last reply
                                  0
                                  • jsulmJ jsulm

                                    @victor-wang Interesting: I can access that URL in a browser but ping does not work.
                                    Maybe there is something with out network? Do you have a proxy? Firewall?

                                    V Offline
                                    V Offline
                                    victor wang
                                    wrote on last edited by
                                    #17

                                    @jsulm
                                    I had find the solution.
                                    Qt cannot recognize the title "www1.winmate" but recognize the IP address for instead.
                                    I changed it into ip address and it worked!

                                    1 Reply Last reply
                                    0
                                    • jsulmJ jsulm

                                      @victor-wang Please read the link I provided. 301 means:
                                      "The HTTP response status code 301 Moved Permanently is used for permanent URL redirection" - it is not related to protocol.

                                      H Offline
                                      H Offline
                                      Hendrik Vennekate
                                      wrote on last edited by
                                      #18

                                      @jsulm I think you are misreading the question: this is not about HTTP status 301 (which would indeed be a redirect), but about the QNetworkReply::NetworkError enum, where 301 means "the Network Access API cannot honor the request because the protocol is not known". I'm currently struggling with a similar issue with a particular Qt build where this pops up for HTTPS (HTTP itself is fine, so I'm guessing I didn't do the SSL dependencies right...)

                                      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