Results 1 to 8 of 8

Thread: Resume download with QHttp

  1. #1
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Resume download with QHttp

    Hello everyone
    I'm writing an app that downloads data from the Internet ( like FlashGet or Download Master ). I need to resume download of a file. I use QHttp like
    Qt Code:
    1. file_ = new QFile(GetDownloadName());
    2. file_->open(QIODevice::Append);
    3.  
    4. QUrl url(downloadURL_);
    5. http_.setHost(url.host());
    6. http_.get(url.path(), file_);
    To copy to clipboard, switch view to plain text mode 
    Maybe I should use some different function like QHttp::request ?
    Last edited by THRESHE; 17th November 2007 at 15:54.
    C++ & AMD forever

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Resume download with QHttp

    Perhaps QHttp::request() and "Content-Range" header field?
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    THRESHE (19th November 2007)

  4. #3
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Resume download with QHttp

    Thanks. It seems that my guess was right
    Last edited by THRESHE; 19th November 2007 at 12:38.
    C++ & AMD forever

  5. #4
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Resume download with QHttp

    It's strange I'm trying to use QHttp::request like this
    Qt Code:
    1. file_ = new QFile(GetDownloadName());
    2. file_->open(QIODevice::Append);
    3.  
    4. QUrl url(downloadURL_);
    5. http_.setHost(url.host());
    6.  
    7. QHttpRequestHeader header("GET", url.path());
    8. header.addValue("Content-Range", "bytes 21010-47021/47022");
    9. qDebug()<<header.toString();
    10. http_.request(header,0, file_);
    To copy to clipboard, switch view to plain text mode 
    But it downloads the whole file not just 21010-47021 bytes
    C++ & AMD forever

  6. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Resume download with QHttp

    Oops, "Content-Range" is a field of server response header. I think the corresponding client request header field is actually just "Range".
    J-P Nurmi

  7. #6
    Join Date
    Mar 2010
    Posts
    92
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Resume download with QHttp

    i want find document funcition header.addValue("Content-Range", "bytes 21010-47021/47022");

  8. #7
    Join Date
    Mar 2010
    Posts
    92
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Resume download with QHttp

    i dont known qHeader.addValue("Range", "bytes 21010-47021/47022");

  9. #8
    Join Date
    Mar 2010
    Posts
    92
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Resume download with QHttp

    Qt Code:
    1. void BrowseWidgetImpl::downloadSubjectForNextThread()
    2. {
    3. if(nextThreadConnection.state() == QHttp::Reading)
    4. {
    5. reloadCompleted();
    6. return;
    7. }
    8. nextThreadConnection.abort();
    9. if(nextThreadBuffer)
    10. {
    11. delete nextThreadBuffer;
    12. nextThreadBuffer = NULL;
    13. }
    14. QUrl subjectUrl(threadUrl.mid(0, threadUrl.lastIndexOf("dat/")) + "subject.txt");
    15. // nextThreadBuffer.size(0);
    16. nextThreadBuffer = new QBuffer;
    17. if(!nextThreadBuffer->open(QIODevice::ReadWrite))
    18. {
    19. qDebug() << "Can't open buffer in downloadSubjectForNextThread()";
    20. return;
    21. }
    22. nextThreadConnection.setProxy(*networkProxy);
    23. nextThreadConnection.setHost(subjectUrl.host());
    24. header.setRequest("GET", subjectUrl.path());
    25. header.addValue("Host", subjectUrl.host());
    26. header.addValue("User-Agent", QString("Monazilla/1.00(%1)").arg(APPNAME));
    27. subjectGetId = nextThreadConnection.request(header, 0, nextThreadBuffer);
    28. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. How to limit download speed with QHttp ?
    By THRESHE in forum Qt Programming
    Replies: 6
    Last Post: 25th November 2010, 11:55
  2. From QHttp to QHttp over SSL
    By Nyphel in forum Newbie
    Replies: 1
    Last Post: 3rd July 2007, 10:41
  3. QHttp download file problem.
    By fengtian.we in forum Qt Programming
    Replies: 12
    Last Post: 12th June 2007, 09:39

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.