Results 1 to 13 of 13

Thread: QHttp download file problem.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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?

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

    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 

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

    Default Re: QHttp download file problem.

    ??? what mean?

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

    Default Re: QHttp download file problem.

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

  5. #5
    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

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    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
  •  
Qt is a trademark of The Qt Company.