QHttpRequestHeader download from 1 byte to 1000 byte - part File ?
Code:
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);
}
Code:
{
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();
}
}
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 :
http://c.upanh.com/upload/5/319/VZ0.9474636_1_1.png
Re: QHttpRequestHeader download from 1 byte to 1000 byte - part File ?
So? Did you check the reason?
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.
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.