Results 1 to 13 of 13

Thread: QHttp download file problem.

  1. #1
    Join Date
    Feb 2007
    Posts
    71
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Question QHttp download file problem.

    #include <QApplication>
    #include <QHttp>
    #include <QUrl>
    #include <QFileInfo>
    #include <QFile>
    #include <QtDebug>

    class QHttp;

    int main(int argc,char *argv[])
    {
    QApplication qapp(argc,argv);
    QHttp *http;
    http=new QHttp();
    QUrl *url=new QUrl("http://feymercurial.com/forum/profile.php?mode=viewprofile&u=873");

    QFileInfo fileinfo(url->path());


    QFile *file = new QFile(fileinfo.fileName());
    file->open(QIODevice::WriteOnly);

    http->setHost(url->host(),80);
    int httpGetId=http->get(url->path(),file);
    qDebug() << httpGetId;

    return qapp.exec();
    }

    --------------------------------


    QUrl *url=new QUrl("http://feymercurial.com/forum/profile.php?mode=viewprofile&u=873");
    file profile.php is empty.

    but if : QUrl *url=new QUrl("http://www.a2gold.com/index_en.php");

    the file index_en.php is have content.

    why?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QHttp download file problem.

    Are you implementing some spam related software?

  3. #3
    Join Date
    Feb 2007
    Posts
    71
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QHttp download file problem.

    NO NO~ haha~

    my Boss will salesmanship some our product, so let me find MSN number~

    our product is about game WOW.

    I think this not spam related software

  4. #4
    Join Date
    Feb 2007
    Posts
    71
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QHttp download file problem.

    help me ~ please~

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QHttp download file problem.

    Start by moving that QUrl object to stack.Then connect to QHttp signals that transmit information about the response header and display the header contents, it'll probably tell you something important (at least the status code).

  6. #6
    Join Date
    Feb 2007
    Posts
    71
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QHttp download file problem.

    ok , let me try

  7. #7
    Join Date
    Feb 2007
    Posts
    71
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Question QHttp download file problem.

    My case:
    page with parameter can download:http://www.a2gold.com/index_en.php
    page without parameter,can't download:http://feymercurial.com/forum/profil...wprofile&u=873


    Code:

    Qt Code:
    1. int main(int argc,char *argv[])
    2. {
    3. QApplication qapp(argc,argv);
    4. QHttp *http;
    5. http=new QHttp();
    6.  
    7. //QUrl *url=new QUrl("http://feymercurial.com/forum/profile.php?mode=viewprofile&u=873"); [COLOR="red"] //this can't download. [/COLOR]
    8.  
    9. QUrl *url=new QUrl("http://www.a2gold.com/index_en.php"); [COLOR="Red"] //this can download. [/COLOR]
    10.  
    11. QFileInfo fileinfo(url->path());
    12.  
    13.  
    14. QFile *file = new QFile(fileinfo.fileName());
    15. file->open(QIODevice::WriteOnly);
    16.  
    17. http->setHost(url->host(),80);
    18. int httpGetId=http->get(url->path(),file);
    19. qDebug() << httpGetId;
    20.  
    21. return qapp.exec();
    22. }
    To copy to clipboard, switch view to plain text mode 

    how can i download a page with a parameter?

  8. #8
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QHttp download file problem.

    Simply dont use path(), instead use text parsing, here is an example:
    Qt Code:
    1. bool HttpGetFile::ParseUrl( const QString& qstrUrlIn, int& iError )
    2. {
    3. QString qstrUrl = qstrUrlIn;
    4.  
    5. QUrl qUrl( qstrUrl );
    6.  
    7. if( qstrUrlIn.length() == (qUrl.scheme().length() + 3 + qUrl.host().length()) )
    8. {
    9. qstrUrl += "/";
    10. qUrl = qstrUrl;
    11. }
    12.  
    13. if( !qUrl.isValid() )
    14. {
    15. iError = 8;
    16. return false;
    17. }
    18.  
    19. if( qUrl.scheme() != "http" )
    20. {
    21. iError = 9;
    22. return false;
    23. }
    24.  
    25. qstrHost = qUrl.host();
    26. qstrPath = qstrUrl.remove( 0, 7 + qstrHost.length() );// 7 == http://
    27.  
    28. return true;
    29. }
    To copy to clipboard, switch view to plain text mode 

  9. #9
    Join Date
    Feb 2007
    Posts
    71
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QHttp download file problem.

    ??? what mean?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QHttp download file problem.

    Quote Originally Posted by fengtian.we View Post
    my Boss will salesmanship some our product, so let me find MSN number
    What do you intend to do with those numbers? Because if you want to send them a message "hey, buy our great software", then that's spamming.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QHttp download file problem.

    Please, don't start more than one thread on the same problem. Threads merged.

  12. #12
    Join Date
    Feb 2007
    Posts
    71
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QHttp download file problem.

    my boss sell the WOW(online game) gold

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QHttp download file problem.

    This doesn't answer my question.

Similar Threads

  1. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  2. Problem : use QHttp get a file to QFile
    By fengtian.we in forum Qt Programming
    Replies: 9
    Last Post: 24th May 2007, 10:58
  3. QHttp Problem
    By musaulker in forum Newbie
    Replies: 4
    Last Post: 29th March 2007, 00:40
  4. Retrieving modified date of file using QHttp
    By hardgeus in forum Qt Programming
    Replies: 9
    Last Post: 3rd December 2006, 23:20
  5. QHttp "PUT METHOD" QT Problem File Upload. RFC 2616
    By patrik08 in forum Qt Programming
    Replies: 7
    Last Post: 25th October 2006, 22:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.