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:



Qt Code:
  1. void HttpWindow::downloadFile()
  2. {
  3. QString qsLink = urlLineEdit->text();
  4. QUrl quUrl(qsLink);
  5. QString qsUrlPath = quUrl.path();
  6. QFileInfo qfiFileInfor(qsUrlPath);
  7. QString qsFileName = qfiFileInfor.fileName();
  8. if (qsFileName.isEmpty())
  9. qsFileName = "index.html";
  10.  
  11. if (QFile::exists(qsFileName)) {
  12. 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){
  13. return;
  14. }
  15. QFile::remove(qsFileName);
  16. }
  17. qfFileOut = new QFile(qsFileName);
  18. if (!qfFileOut->open(QIODevice::WriteOnly)) {
  19. QMessageBox::information(this, tr("HTTP"),tr("Unable to save the file %1: %2.").arg(qsFileName).arg(qfFileOut->errorString()));
  20. delete qfFileOut;
  21. qfFileOut = 0;
  22. return;
  23. }
  24. QString qsHost = quUrl.host();
  25. QHttp::ConnectionMode qhconMode = quUrl.scheme().toLower() == "https" ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp;
  26. qhHttp->setHost(qsHost, qhconMode, quUrl.port() == -1 ? 0 : quUrl.port());
  27. if (!quUrl.userName().isEmpty())
  28. qhHttp->setUser(quUrl.userName(), quUrl.password());
  29. bHttpRequestAborted = false;
  30. QByteArray qbaUrlPath = QUrl::toPercentEncoding(qsUrlPath, "!$&'()*+,;=:@/");
  31. if (qbaUrlPath.isEmpty())
  32. qbaUrlPath = "/";//_________________________________________
  33. QHttpRequestHeader *qhrhHeader = new QHttpRequestHeader("GET", qbaUrlPath);
  34. qhrhHeader->setValue("Connection", "Keep-Alive");
  35. qhrhHeader->setValue("Accept-Ranges", "byte");
  36. /*qhrhHeader->setValue("Content-Length", "1024");
  37. qhrhHeader->setValue("Content-Type", "application/x-rar-compressed");*/
  38. qhrhHeader->setValue("User-Agent", "Mozilla/5.0");
  39. qhrhHeader->setValue("Range", "bytes=0-999");
  40. qhrhHeader->setValue("Host", qsHost);
  41. iHttpGetId = qhHttp->request(*qhrhHeader, 0, qfFileOut);//_________________________________
  42. qpProgressDialog->setWindowTitle(tr("HTTP"));
  43. qpProgressDialog->setLabelText(tr("Downloading %1.").arg(qsFileName));
  44. downloadButton->setEnabled(false);
  45. }
To copy to clipboard, switch view to plain text mode 


but when i build it return on funcition is 206





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