PDA

View Full Version : HTTP Range Option Error 206



nhs_0702
21st April 2010, 11:43
Hi dear all,

I'm reading the code of QT attached http sample(examples\network\http).

In HttpWindow::downloadFile(), I added a key&value pair to the
QHttpRequestHeader, like this:




void HttpWindow::downloadFile()
{
QString qsLink = urlLineEdit->text();
QUrl quUrl(qsLink);
QString qsUrlPath = quUrl.path();
QFileInfo qfiFileInfor(qsUrlPath);
QString qsFileName = qfiFileInfor.fileName();
if (qsFileName.isEmpty())
qsFileName = "index.html";

if (QFile::exists(qsFileName)) {
if (QMessageBox::question(this, tr("HTTP"), tr("There already exists a file called %1 in the current directory. Overwrite?").arg(qsFileName), QMessageBox::Yes|QMessageBox::No, QMessageBox::No)== QMessageBox::No){
return;
}
QFile::remove(qsFileName);
}
qfFileOut = new QFile(qsFileName);
if (!qfFileOut->open(QIODevice::WriteOnly)) {
QMessageBox::information(this, tr("HTTP"),tr("Unable to save the file %1: %2.").arg(qsFileName).arg(qfFileOut->errorString()));
delete qfFileOut;
qfFileOut = 0;
return;
}
QString qsHost = quUrl.host();
QHttp::ConnectionMode qhconMode = quUrl.scheme().toLower() == "https" ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp;
qhHttp->setHost(qsHost, qhconMode, quUrl.port() == -1 ? 0 : quUrl.port());
if (!quUrl.userName().isEmpty())
qhHttp->setUser(quUrl.userName(), quUrl.password());
bHttpRequestAborted = false;
QByteArray qbaUrlPath = QUrl::toPercentEncoding(qsUrlPath, "!$&'()*+,;=:@/");
if (qbaUrlPath.isEmpty())
qbaUrlPath = "/";//_________________________________________
QHttpRequestHeader *qhrhHeader = new QHttpRequestHeader("GET", qbaUrlPath);
qhrhHeader->setValue("Connection", "Keep-Alive");
qhrhHeader->setValue("Accept-Ranges", "byte");
/*qhrhHeader->setValue("Content-Length", "1024");
qhrhHeader->setValue("Content-Type", "application/x-rar-compressed");*/
qhrhHeader->setValue("User-Agent", "Mozilla/5.0");
qhrhHeader->setValue("Range", "bytes=0-999");
qhrhHeader->setValue("Host", qsHost);
iHttpGetId = qhHttp->request(*qhrhHeader, 0, qfFileOut);//_________________________________
qpProgressDialog->setWindowTitle(tr("HTTP"));
qpProgressDialog->setLabelText(tr("Downloading %1.").arg(qsFileName));
downloadButton->setEnabled(false);
}


but when i build it return on funcition is 206

http://c.upanh.com/upload/5/415/3L0.9571069_1_1.png




10.2.7 206 Partial Content

The server has fulfilled the partial GET request for the resource. The request MUST have included a Range header field (section 14.35) indicating the desired range, and MAY have included an If-Range header field (section 14.27) to make the request conditional.

The response MUST include the following header fields:

- Either a Content-Range header field (section 14.16) indicating
the range included with this response, or a multipart/byteranges
Content-Type including Content-Range fields for each part. If a
Content-Length header field is present in the response, its
value MUST match the actual number of OCTETs transmitted in the
message-body.

- Date

- ETag and/or Content-Location, if the header would have been sent
in a 200 response to the same request

- Expires, Cache-Control, and/or Vary, if the field-value might
differ from that sent in any previous response for the same
variant

If the 206 response is the result of an If-Range request that used a strong cache validator (see section 13.3.3), the response SHOULD NOT include other entity-headers. If the response is the result of an If-Range request that used a weak validator, the response MUST NOT include other entity-headers; this prevents inconsistencies between cached entity-bodies and updated headers. Otherwise, the response MUST include all of the entity-headers that would have been returned with a 200 (OK) response to the same request.

A cache MUST NOT combine a 206 response with other previously cached content if the ETag or Last-Modified headers do not match exactly, see 13.5.4.

A cache that does not support the Range and Content-Range headers MUST NOT cache 206 (Partial) responses.


can you help me and edit my source

http://www.mediafire.com/?dzjaztigrnm

squidge
21st April 2010, 12:25
Will you please stop double posting. Post in one forum ONLY.

There are replies in your other topic.