PDA

View Full Version : The "Range" option in QHttpRequestHeader



nhs_0702
20th April 2010, 08:50
#include <QtCore/QCoreApplication>
#include <qtGUI/QMessageBox>
#include <QHttp>
#include <QHttpRequestHeader>
#include <QFile>
#include <QFileInfo>
#include <QUrl>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);//_______
QString qsUrlLink = "http://cpowone.com/Embedded%20Systems.rar";
QFileInfo qfFileInfo(qsUrlLink);
QString qsFileName = qfFileInfo.fileName();
if (qsFileName.isEmpty())
qsFileName = "index.html";
QUrl quSubjectUrl(qsUrlLink);
QHttp *hHttp = new QHttp();
QHttpRequestHeader *qhHeader = new QHttpRequestHeader("GET", quSubjectUrl.path());
QString qsHost = quSubjectUrl.host();
qhHeader->setValue("Host", qsHost);
qhHeader->setValue("Content-Range", QString("bytes=1-1024"));
hHttp->setHost(qsHost, 80);
QFile *qfFileOut;
qfFileOut = new QFile(qsFileName);
if(!qfFileOut->open(QIODevice::WriteOnly)){
delete qfFileOut;
qfFileOut = 0;
return 0;
}
hHttp->request(*qhHeader,0,qfFileOut);
return a.exec();
}



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


http://c.upanh.com/upload/5/367/CS0.9522995_1_1.png

nhs_0702
20th April 2010, 11:54
when i download html then it download oK,Ex i download link : http://www.qtforum.org/article/17312/the-range-option-in-qhttprequestheader-does-not-work.html
but when i download binary file it error