HTTP Range Option Error 206
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:
Code:
void HttpWindow::downloadFile()
{
QString qsLink
= urlLineEdit
->text
();
QString qsFileName
= qfiFileInfor.
fileName();
if (qsFileName.isEmpty())
qsFileName = "index.html";
if (QFile::exists(qsFileName
)) { 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;
}
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 = "/";//_________________________________________
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
Quote:
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
Re: HTTP Range Option Error 206
Will you please stop double posting. Post in one forum ONLY.
There are replies in your other topic.