Results 1 to 2 of 2

Thread: The "Range" option in QHttpRequestHeader

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

    Default The "Range" option in QHttpRequestHeader

    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include <qtGUI/QMessageBox>
    3. #include <QHttp>
    4. #include <QHttpRequestHeader>
    5. #include <QFile>
    6. #include <QFileInfo>
    7. #include <QUrl>
    8. int main(int argc, char *argv[])
    9. {
    10. QCoreApplication a(argc, argv);//_______
    11. QString qsUrlLink = "http://cpowone.com/Embedded%20Systems.rar";
    12. QFileInfo qfFileInfo(qsUrlLink);
    13. QString qsFileName = qfFileInfo.fileName();
    14. if (qsFileName.isEmpty())
    15. qsFileName = "index.html";
    16. QUrl quSubjectUrl(qsUrlLink);
    17. QHttp *hHttp = new QHttp();
    18. QHttpRequestHeader *qhHeader = new QHttpRequestHeader("GET", quSubjectUrl.path());
    19. QString qsHost = quSubjectUrl.host();
    20. qhHeader->setValue("Host", qsHost);
    21. qhHeader->setValue("Content-Range", QString("bytes=1-1024"));
    22. hHttp->setHost(qsHost, 80);
    23. QFile *qfFileOut;
    24. qfFileOut = new QFile(qsFileName);
    25. if(!qfFileOut->open(QIODevice::WriteOnly)){
    26. delete qfFileOut;
    27. qfFileOut = 0;
    28. return 0;
    29. }
    30. hHttp->request(*qhHeader,0,qfFileOut);
    31. return a.exec();
    32. }
    To copy to clipboard, switch view to plain text mode 


    i download file on internet but it error beacause it cant download form http://cpowone.com/Embedded%20Systems.rar
    can you help me ?


    Last edited by nhs_0702; 20th April 2010 at 09:16.

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

    Default Re: The "Range" option in QHttpRequestHeader

    when i download html then it download oK,Ex i download link : http://www.qtforum.org/article/17312...-not-work.html
    but when i download binary file it error

Similar Threads

  1. The "Range" option in QHttpRequestHeader does not work?
    By nhs_0702 in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2010, 09:36
  2. Replies: 1
    Last Post: 5th January 2010, 13:34
  3. setWritingSystem gives "out of range" error
    By jano_alex_es in forum Newbie
    Replies: 0
    Last Post: 2nd October 2009, 11:33
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

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.