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] QNetworkAccessManager failing to retrieve data
QtWS25 Last Chance

[SOLVED] QNetworkAccessManager failing to retrieve data

Scheduled Pinned Locked Moved General and Desktop
10 Posts 4 Posters 7.9k 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
    blackpaw
    wrote on last edited by
    #1

    Edited: Environment
    Qt 4.7.4
    KDE 4.7.1
    Kubuntu 11.10

    I'm trying to pull back data from an url ("http://whirlpool.net.au":http://whirlpool.net.au), code as follows:

    @
    void KWhirlMonView::refresh()
    {
    QUrl url("http://whirlpool.net.au");
    QNetworkRequest request(url);

    reply = qnam.get(request);
    connect(reply, SIGNAL(finished()),
            this, SLOT(httpFinished()));
    connect(reply, SIGNAL(readyRead()),
            this, SLOT(httpReadyRead()));
    connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
            this, SLOT(updateDataReadProgress(qint64,qint64)));
    
    connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
            this, SLOT(httpError(QNetworkReply::NetworkError)));
    

    }

    void KWhirlMonView::httpFinished()
    {
    kDebug() << "httpFinished - " << reply->errorString() << endl;
    QByteArray data = reply->readAll();
    QString s(data);
    kDebug() << s << endl;
    }

    void KWhirlMonView::httpError ( QNetworkReply::NetworkError code )
    {
    kDebug() << code << endl;
    }

    @

    the error slot always triggers with error code 203
    The error String is "Error downloading http://whirlpool.net.au - server replied: Not found"
    The data returned is : "<html><body>The requested resource could not be found.</body></html>"

    I can open the site fine with any browser and other windows SDK code (delphi + indy httpClient)

    Any suggestions?

    Thanks - Lindsay

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Your first referenced link on this page here is broken (first line). It includes ")," .

      Vote the answer(s) that helped you to solve your issue(s)

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

        I don't understand your point - thats just the forum software mangling the link I posted. You'll note the actual code I posted has the correct url - "http://whirlpool.net.au":http://whirlpool.net.au

        1 Reply Last reply
        0
        • B Offline
          B Offline
          blackpaw
          wrote on last edited by
          #4

          ps - Thanks though! :)

          1 Reply Last reply
          0
          • K Offline
            K Offline
            koahnig
            wrote on last edited by
            #5

            Sorry, it is just a problem in your positing.
            In the first line of your post you have attached immediately after the link a ')' and a ','.
            If one tries to follow this link, one will get an error message. This is a problem of devnet.
            Unfortunately, it does not address your actual problem.

            [Edit] Someone has fixed it in the mean time.

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            0
            • B Offline
              B Offline
              blackpaw
              wrote on last edited by
              #6

              That was me :) thanks for the heads up

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

                I should add - tried the code with "http://google.com":http://google.com, that worked fine (retrieved the content)

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  lgeyer
                  wrote on last edited by
                  #8

                  Have you tried to use Wireshark or tcpdump to spot the difference between the two requests?
                  What does qDebug() << reply->request()->url() say?

                  Probably the site has some restrictions based on user agent or access pattern to block your request. At least they have some sense of "humor":http://whirlpool.net.au/index.php ;-)

                  1 Reply Last reply
                  0
                  • Z Offline
                    Z Offline
                    zither
                    wrote on last edited by
                    #9

                    Some error in code?
                    I think
                    @reply = qnam.get(request);@

                    Should be
                    @reply = qname->get(request);@

                    you should check, like Lukas Geyer says to check your url reqest.
                    @qDebug()<<reply->request()->url@

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      blackpaw
                      wrote on last edited by
                      #10

                      Thanks Lucas, that definietly got me on the right track - once I set the user agent to "Mozilla ..." etc I started getting info back. Now having problems with the cgi parameters but I'll sort that.

                      Might have a word with the site admin about the UA requirement - doesn't seem neccessary ...

                      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