void HttpWindow::resumeDownloadFile()
{
QString qEditUrl
= urlLineEdit
->text
();
QString fileName
= fileInfo.
fileName();
if (fileName.isEmpty())
fileName = "index.html";
QUrl subjectUrl
(qEditUrl
);
qfFileOut
= new QFile(fileName
);
return;
}
http->setHost(subjectUrl.host());
qHeader.setRequest("GET", subjectUrl.path());
qHeader.addValue("Host", subjectUrl.host());
qHeader.
addValue("Range",
QString("bytes=1-1000"));
httpRequestAborted = false;
httpGetId = http->request(qHeader, 0, qfFileOut);
progressDialog->setWindowTitle(tr("HTTP"));
progressDialog->setLabelText(tr("Downloading %1.").arg(fileName));
downloadButton->setEnabled(false);
}
void HttpWindow::resumeDownloadFile()
{
QString qEditUrl = urlLineEdit->text();
QFileInfo fileInfo(qEditUrl);
QString fileName = fileInfo.fileName();
if (fileName.isEmpty())
fileName = "index.html";
QUrl subjectUrl(qEditUrl);
qfFileOut = new QFile(fileName);
if(!qfFileOut->open(QIODevice::WriteOnly)){
return;
}
QHttpRequestHeader qHeader;
http->setHost(subjectUrl.host());
qHeader.setRequest("GET", subjectUrl.path());
qHeader.addValue("Host", subjectUrl.host());
qHeader.addValue("Range", QString("bytes=1-1000"));
httpRequestAborted = false;
httpGetId = http->request(qHeader, 0, qfFileOut);
progressDialog->setWindowTitle(tr("HTTP"));
progressDialog->setLabelText(tr("Downloading %1.").arg(fileName));
downloadButton->setEnabled(false);
}
To copy to clipboard, switch view to plain text mode
{
switch (responseHeader.statusCode()) {
case 200: // Ok
case 301: // Moved Permanently
case 302: // Found
case 303: // See Other
case 307:
break;// Temporary Redirect
default:
QMessageBox::information(this, tr
("HTTP"),tr
("Error Response Header : %1.").
arg(responseHeader.
reasonPhrase()));
httpRequestAborted = true;
progressDialog->hide();
//http->abort();
}
}
void HttpWindow::readResponseHeader(const QHttpResponseHeader &responseHeader)
{
switch (responseHeader.statusCode()) {
case 200: // Ok
case 301: // Moved Permanently
case 302: // Found
case 303: // See Other
case 307:
break;// Temporary Redirect
default:
QMessageBox::information(this, tr("HTTP"),tr("Error Response Header : %1.").arg(responseHeader.reasonPhrase()));
httpRequestAborted = true;
progressDialog->hide();
//http->abort();
}
}
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 :
Bookmarks