Results 1 to 4 of 4

Thread: QHttpRequestHeader download from 1 byte to 1000 byte - part File ?

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

    Default QHttpRequestHeader download from 1 byte to 1000 byte - part File ?

    Qt Code:
    1. void HttpWindow::resumeDownloadFile()
    2. {
    3. QString qEditUrl = urlLineEdit->text();
    4. QFileInfo fileInfo(qEditUrl);
    5. QString fileName = fileInfo.fileName();
    6. if (fileName.isEmpty())
    7. fileName = "index.html";
    8. QUrl subjectUrl(qEditUrl);
    9. qfFileOut = new QFile(fileName);
    10. if(!qfFileOut->open(QIODevice::WriteOnly)){
    11. return;
    12. }
    13. http->setHost(subjectUrl.host());
    14. qHeader.setRequest("GET", subjectUrl.path());
    15. qHeader.addValue("Host", subjectUrl.host());
    16. qHeader.addValue("Range", QString("bytes=1-1000"));
    17. httpRequestAborted = false;
    18. httpGetId = http->request(qHeader, 0, qfFileOut);
    19. progressDialog->setWindowTitle(tr("HTTP"));
    20. progressDialog->setLabelText(tr("Downloading %1.").arg(fileName));
    21. downloadButton->setEnabled(false);
    22. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void HttpWindow::readResponseHeader(const QHttpResponseHeader &responseHeader)
    2. {
    3. switch (responseHeader.statusCode()) {
    4. case 200: // Ok
    5. case 301: // Moved Permanently
    6. case 302: // Found
    7. case 303: // See Other
    8. case 307:
    9. break;// Temporary Redirect
    10. default:
    11. QMessageBox::information(this, tr("HTTP"),tr("Error Response Header : %1.").arg(responseHeader.reasonPhrase()));
    12. httpRequestAborted = true;
    13. progressDialog->hide();
    14. //http->abort();
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 


    i want download 1 file from 1 byte -> 1000 byte ,dont download all,i use funciton
    qHeader.addValue("Range", QString("bytes=1-1000"));
    but it error :





    Last edited by wysota; 19th April 2010 at 10:41.

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

    Default Re: QHttpRequestHeader download from 1 byte to 1000 byte - part File ?

    So? Did you check the reason?

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QHttpRequestHeader download from 1 byte to 1000 byte - part File ?

    Some servers may not support the 'Range' header. This will be stated in the statusCode.

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

    Default Re: QHttpRequestHeader download from 1 byte to 1000 byte - part File ?

    He's getting a 404, so it's not about an unhandled header but rather about a wrong path to the resource.

Similar Threads

  1. Read a Byte from Binary File
    By umulingu in forum Qt Programming
    Replies: 1
    Last Post: 3rd March 2010, 07:20
  2. Converting from char to byte
    By Ferric in forum Newbie
    Replies: 2
    Last Post: 8th January 2010, 01:27
  3. Byte shifting in C
    By tntcoda in forum General Programming
    Replies: 3
    Last Post: 14th November 2008, 23:40
  4. Two Byte character Support
    By rajveer in forum General Programming
    Replies: 10
    Last Post: 25th October 2008, 01:29
  5. convert BYTE* to QString
    By tpf80 in forum Qt Programming
    Replies: 6
    Last Post: 8th April 2007, 11:29

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.